0

I'm using the following configuration for my nginx server:

upstream django {
    server unix:///var/www/example.com/django/ws/django.socket;
}

upstream io_nodes {
  ip_hash;
  server 127.0.0.1:8080;
}

limit_req_zone $binary_remote_addr zone=one:100m rate=1000r/s;

server {
    listen 80;
    server_name example.com;
    root /var/www/example.com;


    location /static {
        alias /var/www/example.com/media;
    }    

    location / {
        limit_req zone=one burst=500 nodelay;
        uwsgi_pass django;
        include /etc/nginx/uwsgi_params;
    }

    location /socket.io/ {
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $host;
        proxy_http_version 1.1;
        proxy_pass http://io_nodes;
    }
}

When I send POST requests to /socket/message, only 5 requests will be handled immediately, the rest will be delayed. After a while, the next 5 requests will be handled and so on. So I assume it has something to do with the limit_req settings, but setting it to a really high value, didn't help. So what could be the problem?

HopelessN00b
  • 53,795
  • 33
  • 135
  • 209
basilikum
  • 217
  • 3
  • 11
  • Have you tried to remove limit_req? I'm pretty sure it's django limit, not nginx – Alexey Ten Feb 09 '15 at 07:28
  • @AlexeyTen Yes, originally I didn't have any limit_req and the problem already occurred. Does django have such a limit? And where can you configure it. I couldn't find any information about it. – basilikum Feb 09 '15 at 09:33
  • There are some more directives that affects number of nginx's connections like `worker_connections` directive. But by default they have some sane value, not 5. – Alexey Ten Feb 09 '15 at 09:41
  • Possibly it's not django's limit written somewhere but performance iisue. I don't know django and python so can't say exactly – Alexey Ten Feb 09 '15 at 09:42
  • What is this "after a while" you speak of? Is it milliseconds or seconds? If milliseconds then this might be because you only have so and so many uwsgi / gunicorn / whatever workers serving the requests. – velis Jun 13 '18 at 05:48

0 Answers0