scgi_connect_timeout
The `scgi_connect_timeout` directive sets the maximum time to establish a connection with an SCGI server in NGINX.
Description
The scgi_connect_timeout directive specifies the timeout for establishing a connection to an SCGI server. This is a crucial setting to determine how long NGINX will wait for a connection to be made before considering it to have failed. If the specified timeout elapses without establishing a connection, NGINX will return an error to the client. The timeout is set in seconds and can be specified as a literal number or in a more human-readable format that includes time units (e.g., '1s', '100ms'). This directive is applicable in several contexts including the http, server, and location blocks.
Understanding the appropriate value to set for scgi_connect_timeout is vital for ensuring that your application remains responsive. A too low value might result in frequent connection timeouts during periods of high load or when the SCGI server is under stress. Conversely, setting it too high may lead to increased latencies, especially if the SCGI server is down or unreachable. Administrators should monitor server performance and connection success rates to determine optimal timeout settings. Adjustments can be made based on the characteristics of the SCGI application being used and network conditions.
Config Example
http {
server {
location / {
scgi_pass 127.0.0.1:9000;
scgi_connect_timeout 5s;
}
}
}Setting the timeout too low may result in unnecessary errors during high traffic periods or heavy server load.
A higher timeout can lead to slow responses for clients if the SCGI server is unresponsive or slow to connect.