Nginx and Gunicorn hanging on GET requests

Posted by whatWhat on Server Fault See other posts from Server Fault or by whatWhat
Published on 2012-09-12T13:50:59Z Indexed on 2012/09/12 15:40 UTC
Read the original article Hit count: 252

Filed under:
|
|

I'm using Nginx + Gunicorn which is serving my Django project. All GET requests hang for ~1 min. The content seems to be available immediately as I can see it in the Browser inspector but the browser itself looks like it's still waiting for more data. Heres my Ngnix config

#allow for up to 3 connections per second.
limit_req_zone  $binary_remote_addr  zone=one:10m   rate=3r/s; 

server {
listen   80;
server_name example.com;

root /var/www/example.com/example/;

# serve directly - analogous for static/staticfiles
location /media/ {
    # this changes depending on your python version
    root /home/example/;
}
location /static/ {
    # if asset versioning is used
    if ($query_string) {
        expires max;
    }
    root /var/www/example.com;
}


location / {

    #Allow for a burst of 50.
    limit_req   zone=one burst=50 nodelay;
    proxy_pass_header Server;
    proxy_set_header Host $http_host;
    proxy_redirect off;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Scheme $scheme;
    proxy_connect_timeout 10;
    proxy_read_timeout 10;
    proxy_pass http://localhost:8001/;
}


# what to serve if upstream is not available or crashes
error_page 500 502 503 504 /media/50x.html;
}

My Gunicorn Config:

bind = "127.0.0.1:8001"
workers = 3
worker_class = "gevent"

Is there anything obvious that would be causing the requests to stay open for so long?

© Server Fault or respective owner

Related posts about nginx

Related posts about django