worker_priority

Sets the priority of worker processes for better scheduling on multi-core systems.

Syntaxworker_priority number;
Defaultnone
Contextmain
Arguments1

Description

The worker_priority directive allows you to specify the nice value for the worker processes in NGINX, which can help influence how the operating system schedules these processes in a multi-core environment. The nice value is an integer ranging from -20 (highest priority) to 19 (lowest priority), allowing for fine control over how CPU resources are allocated to your NGINX workers. This directive is particularly useful in environments where you want to prioritize web traffic handling relative to other system processes, ensuring that the web server can respond quickly and efficiently under load.

By default, NGINX worker processes inherit the system's default priority settings. When you set a specific priority using the worker_priority directive, you aim to make your server's response time more predictable and efficient by reducing the likelihood of contention with other processes that might be consuming CPU resources. It's important to note that setting a high priority for NGINX workers may lead to resource contention for other system processes, so careful consideration of overall system load and requirements is necessary.

When configuring NGINX, be sure to test thoroughly after changing the worker_priority setting, as its effects can vary significantly based on the workload and the architecture of your server. Additionally, not all operating systems may support all values for nice, so it is advisable to refer to the documentation specific to your operating system to ensure compatibility.

Config Example

worker_priority 10;

Setting the priority too high may starve other critical processes on the server, leading to instability.

Not all operating systems support the full range of priority values, which may lead to unexpected behavior.

Exceeding the maximum nice value set by the OS can lead to configuration errors.

← Back to all directives