title: GUnicorn and Django for 500 concurrent requests with limited resources
body: <p>I was tasked with creating a Django-Gunicorn demo app. In this task, I need to be able to handle 500 concurrent login requests in 1 second.</p>
  
  <p>I have to deploy the app in a VM with 2GB RAM and 2 core CPUs (using Vagrant and VirtualBox, Ubuntu 16.04). I already tried the following for deployment.</p>
  
  <p><code>gunicorn --workers 5 --bind "0.0.0.0:8000" --worker-class "gevent" --keep-alive 5 project.wsgi</code></p>
  
  <p>Using JMeter test from the host machine, the test always takes around 7-10 seconds. Even if the login endpoint only returns empty response without any database access, the amount of the time is almost the same. Can you tell me what's wrong with this? </p>
  
  <p>I use the default settings at <code>/etc/nginx/nginx.conf</code>.</p>
  
  <pre><code>user www-data;
  worker_processes auto;
  pid /run/nginx.pid;
  
  events {
      worker_connections 768;
      multi_accept on;
  }
  
  http {
      sendfile on;
      tcp_nopush on;
      tcp_nodelay on;
      keepalive_timeout 65;
      types_hash_max_size 2048;
      # server_tokens off;
  
      # server_names_hash_bucket_size 64;
      # server_name_in_redirect off;
  
      include /etc/nginx/mime.types;
      default_type application/octet-stream;
  
      ##
      # SSL Settings
      ##
  
      ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
      ssl_prefer_server_ciphers on;
  
      ##
      # Logging Settings
      ##
  
      access_log /var/log/nginx/access.log;
      error_log /var/log/nginx/error.log;
  
      ##
      # Gzip Settings
      ##
  
      gzip on;
      gzip_disable "msie6";
  
      ##
      # Virtual Host Configs
      ##
  
      include /etc/nginx/conf.d/*.conf;
      include /etc/nginx/sites-enabled/*;
  }
  </code></pre>
  
  <p>And here is my reverse proxy settings I put in sites-available folder.</p>
  
  <pre><code>server {
      listen 80;
  
      location /static {
          autoindex on;
          alias /vagrant/static/;
      }
  
      location /media {
      autoindex on;
      alias /vagrant/uploads/;
      }
  
      location / {
          proxy_redirect http://127.0.0.1:8000/ http://127.0.0.1:8080/;
          proxy_pass http://127.0.0.1:8000;
      }
  }
  </code></pre>
  
  <p>Thanks</p>