dynamic_upstrand

The 'dynamic_upstrand' directive allows runtime selection of upstreams based on specified parameters.

Syntaxdynamic_upstrand upstream_name [upstream_name2 ...];
Defaultnone
Contextserver, location, if in location
Arguments2+

Description

The 'dynamic_upstrand' directive is a powerful feature provided by the NGINX Combined Upstreams module, enabling users to define upstream servers that can be selected dynamically at runtime. This directive requires at least two arguments, which typically specify the upstream server definitions available for selection. By facilitating runtime configuration, this directive opens up possibilities for more flexible load balancing and resource management, allowing the server to adapt based on the current demand or availability of upstream resources.

When configuring the 'dynamic_upstrand' directive, users can combine various upstream directives to fine-tune how requests should be routed. The parameters passed to this directive determine the operational behavior of how requests interact with defined upstream layers, enhancing performance and reliability. Essentially, it allows NGINX to make decisions about which upstream to route to in a more flexible and responsive manner, adjusting to real-time conditions rather than relying solely on static configurations.

Config Example

location /api {
    dynamic_upstrand primary_servers secondary_servers;
}

Ensure that the number of arguments is at least two, otherwise, NGINX will throw an error during the configuration load.

Watch out for misnamed upstreams; if an upstream does not exist as specified, NGINX may fail to route requests appropriately.

← Back to all directives