vhost_traffic_status_limit_traffic

Limits the traffic for monitored virtual hosts in NGINX.

Syntaxvhost_traffic_status_limit_traffic limit [interval];
Defaultnone
Contexthttp, server, location
Arguments1-2

Description

The vhost_traffic_status_limit_traffic directive in the NGINX virtual host traffic status module is designed to impose traffic limits on monitored virtual hosts. This directive can take one or two arguments. If one argument is provided, it specifies the maximum traffic limit for each virtual host; if two arguments are given, the first one specifies the limit and the second specifies the time interval over which this limit applies. This gives administrators the ability to control bandwidth usage per host, contributing to effective traffic management and potentially balancing load across multiple servers.

The configuration of this directive allows for finer control over resource allocation in environments where many virtual hosts are served. The traffic limit can help prevent any single virtual host from exhausting bandwidth resources, ensuring a fair distribution of available network capacity among all hosted applications. When nearing the specified traffic limit, NGINX can utilize this directive to manage how requests are routed or throttled, although the exact behavior will depend on additional configurations and the specific version of the NGINX server.

Moreover, the utility of this directive extends beyond mere monitoring; it becomes particularly essential in scenarios involving shared resources or multi-tenant architectures where one client’s high traffic could adversely affect others. Applying traffic limits can help isolate the impact of such traffic surges, maintaining overall server performance and stability.

Config Example

http {
    vhost_traffic_status_zone;
    server {
        location /status {
            vhost_traffic_status;
        }
        vhost_traffic_status_limit_traffic 100m 1s;
    }
}

Ensure that the interval is appropriate for your use case; too short may lead to excessive throttling.

Limits apply only to monitored virtual hosts, so make sure the directive is used in the correct context.

The directive may not behave as expected without correct upstream and caching configurations.

← Back to all directives