fastcgi_next_upstream_timeout
Sets the timeout for FastCGI next upstream requests in NGINX.
Description
The fastcgi_next_upstream_timeout directive defines a timeout duration for subsequent FastCGI requests when the initial request fails. This directive provides fine-grained control over how long the server will wait before giving up on a FastCGI upstream after the first attempt fails. Specifying this timeout can be crucial for applications where response time is critical, and where the server may retry requests to a different backend to obtain a swift response. The timeout can be set in different contexts including http, server, and location blocks, allowing for flexibility based on the configuration needs.
The directive accepts a time value as an argument, typically in seconds. If the specified timeout is reached without receiving a response from the upstream FastCGI server, NGINX will halt the request and process the next upstream similarly. This behavior ensures that servers are responsive and can handle failures from FastCGI applications gracefully. At times developers might want to tweak this timeout based on their application performance and necessary failover strategies to ensure higher availability and lower latency in serving requests.
Config Example
location /api {
fastcgi_pass backend;
fastcgi_next_upstream_timeout 10s;
include fastcgi_params;
}Ensure the timeout is set to a sensible value to avoid excessive delay during retries.
Using a very short timeout may lead to frequent request failures if the upstream server is slow to respond.