grpc_next_upstream_tries

The `grpc_next_upstream_tries` directive controls the number of attempts to contact upstream servers when processing client requests using gRPC.

Syntaxgrpc_next_upstream_tries number;
Default1
Contexthttp, server, location
Arguments1

Description

The grpc_next_upstream_tries directive specifies how many upstream servers NGINX should attempt to contact in case the previous server fails to respond. When a gRPC request is processed, if the first upstream server returns an error, NGINX can retry the request to subsequent servers based on this directive's value. The directive can be useful in load-balanced environments to ensure reliability in client-server communications by allowing fallback to alternate servers when issues are encountered. The retry mechanism is beneficial for transient failures but should be measured against potential increased latencies in client response times.

This directive operates in the contexts of http, server, and location. The value set for grpc_next_upstream_tries must be a positive integer, which denotes the number of retries allowed when an upstream request fails. If the directive is set to 0, it disables the retries entirely, leading to immediate failure after the first upstream server is contacted. The default behavior is defined by the server administrator's configuration and can be adjusted to balance performance with reliability based on application needs.

Config Example

grpc_next_upstream_tries 3;

Setting the value to 0 disables retries, which may lead to immediate failures during upstream errors.

Ensure that the upstream servers are correctly configured to handle retried requests when applicable.

← Back to all directives