1

$request_time in nginx logs is the time taken by the request from when it was first received in nginx and till the response was sent back by nginx to client.

In my nginx config, the request is closed by nginx and marked 504 gateway timeout when $request_time reaches 60s

I have tried using following location context directives:

proxy_connect_timeout       300s;
proxy_send_timeout          300s;
proxy_read_timeout          300s;
send_timeout                300s;
uwsgi_read_timeout          300s;
uwsgi_send_timeout          300s;

But still facing the same issue. Is there some config that i am missing?

Here is the location context of my nginx.conf

location / {
        set $uwsgi_script "wsgi";
        set $script_name "/";
        set $socket "uwsgi.sock";

        #client_max_body_size 1000m;
        keepalive_timeout  0;

        # host and port to uwsgi server
        uwsgi_pass   unix:///tmp/$socket;
        uwsgi_param  UWSGI_SCRIPT $uwsgi_script;
        uwsgi_param  SCRIPT_NAME $script_name;

        proxy_connect_timeout       300s;
        proxy_send_timeout          300s;
        proxy_read_timeout          300s;
        send_timeout                300s;

        uwsgi_pass_header Authorization;
        include /etc/nginx/uwsgi_params;

        #fix redirect issue to proxy port
        uwsgi_param SERVER_PORT 80;

        #set correct scheme
        uwsgi_param UWSGI_SCHEME $http_x_forwarded_proto;

        uwsgi_intercept_errors off;
        uwsgi_read_timeout          300s;
        uwsgi_send_timeout          300s;
    }
Ry-
  • 218,210
  • 55
  • 464
  • 476
varun
  • 1,473
  • 1
  • 9
  • 15

1 Answers1

1

This is not because nginx is timing out the request. This is being timed out at uwsgi level itself.

harakiri

A feature of uWSGI that aborts workers that are serving requests for an excessively long time. Configured using the harakiri family of options. Every request that will take longer than the seconds specified in the harakiri timeout will be dropped and the corresponding worker recycled.

So you need to the set harakiri parameter in your uwsgi config. See below also for more details

uWSGI request timeout in Python

Community
  • 1
  • 1
Tarun Lalwani
  • 142,312
  • 9
  • 204
  • 265