grpc_next_upstream_timeout

Sets the timeout for the next upstream server connection in gRPC requests.

Syntaxgrpc_next_upstream_timeout time;
Defaultnone
Contexthttp, server, location
Arguments1

Description

The grpc_next_upstream_timeout directive specifies the maximum time to wait for a connection to the next upstream server when the previous upstream server fails during a gRPC request. This timeout is essential in scenarios where multiple upstream servers can take part in handling a client request. If the initial upstream server encounters an error, the configured timeout determines how long NGINX will attempt to connect to the next available upstream server in the stack before timing out the operation.

The parameter for grpc_next_upstream_timeout is defined in milliseconds, allowing fine-grained control over how quickly a response can be generated even in adverse conditions where the primary server is unresponsive or slow. It directly affects the efficiency and responsiveness of the service, particularly in cases of high failure rates or latency among upstream servers. By configuring this directive, administrators can optimize user experience and resource usage by balancing between waiting for server responses and failing over to alternative servers.

This directive can be set in various contexts such as http, server, and location, making it versatile across different levels of configuration. Using it in combination with related directives such as grpc_pass or proxy_next_upstream can further enhance overall server functionality and reliability.

Config Example

location /api {
    grpc_pass grpc://my_upstream;
    grpc_next_upstream_timeout 500ms;
}

Ensure the time specified is appropriate for your application's performance needs; a very short timeout may cause excessive failovers, while a long timeout may delay responses.

This directive is only effective when gRPC is being used; ensure your upstream server is configured accordingly.

← Back to all directives