uWSGI request timeout in Python

前端 未结 2 827
孤城傲影
孤城傲影 2020-11-30 02:37

Trying to set the timeout for requests in uWSGI, I\'m not sure of the correct setting. There seem to be multiple timeout options (socket, interface, etc.) and it\'s not rea

相关标签:
2条回答
  • 2020-11-30 02:50

    Setting http-timeout worked for me. I have http = :8080, so I assume if you use file system socket, you have to use socket-timeout.

    0 讨论(0)
  • 2020-11-30 02:56

    You're propably looking for the harakiri parameter - if request takes longer than specified harakiri time (in seconds), the request will be dropped and the corresponding worker recycled.

    For standalone uwsgi (ini config):

    [uwsgi]
    http = 0.0.0.0:80
    harakiri = 30
    ...
    

    If you have nginx proxy before uwsgi you have to increase timeout as well:

      location / {
        proxy_pass http://my_uwsgi_upstream;
        proxy_read_timeout 30s;
        proxy_send_timeout 30s;
      }
    

    If you want (for some strange reason) higher timeout than 60s, you might consider communication over uwsgi protocol. Configuration is quite similar nginx site:

    location / {
        uwsgi_read_timeout 120s;
        uwsgi_send_timeout 120s;
        uwsgi_pass  my_upstream;
        include     uwsgi_params;
    }
    

    uwsgi:

    [uwsgi]
    socket = 0.0.0.0:80
    protocol = uwsgi
    harakiri = 120
    ...
    
    0 讨论(0)
提交回复
热议问题