uwsgi_read_timeout
Sets the timeout for reading the response from a uWSGI server in NGINX.
Description
The uwsgi_read_timeout directive specifies the duration that NGINX will wait for a response from a uWSGI server. If the server does not respond within this timeframe, NGINX will close the connection and return an error to the client. This parameter is particularly useful for applications that may take longer to process requests, ensuring that NGINX does not hold connections open indefinitely.
The timeout value can be specified in various time formats, such as seconds, minutes, or more granular formats like milliseconds. The primary usage is to enhance performance by avoiding long waits for unresponsive backends. Administrators can configure this time limit differently for various contexts by setting the directive in the http, server, or location blocks, providing flexibility according to specific requirements.
If the uwsgi_read_timeout limit is exceeded, NGINX will return a 504 Gateway Timeout error, signaling to the client that the connection has failed due to the uWSGI server not responding in the allocated time. Therefore, it's advisable to analyze application response times and set this value to balance between allowing enough time for processing while ensuring that clients are not kept waiting too long.
Config Example
location /app {
include uwsgi_params;
uwsgi_pass unix:/path/to/socket;
uwsgi_read_timeout 30s;
}Setting this timeout too low may cause legitimate requests to fail if the app takes longer to respond.
If not set carefully, clients may experience timeouts on long-running requests without proper error handling in place.