worker_shutdown_timeout

Sets the timeout for graceful shutdown of worker processes in NGINX.

Syntaxworker_shutdown_timeout time;
Default60000
Contextmain
Arguments1

Description

The worker_shutdown_timeout directive in NGINX specifies the duration (in milliseconds) that NGINX will wait for worker processes to gracefully shut down after a termination signal is received. This allows workers to complete ongoing requests and clean up resources before being forcefully shut down. This is particularly useful in scenarios where long-lived connections or large requests may need extra time to finish processing.

If a worker process does not complete its operations within the specified timeout period, NGINX will forcibly kill these processes. Setting this value too low can result in active requests being interrupted, leading to potential data loss or incomplete transactions. Conversely, setting it too high might delay the application restart or shut down, which can affect application availability during maintenance or updates. In practice, setting a thoughtful value here balances between service continuity and efficient resource management during upgrades or graceful restarts.

Config Example

worker_shutdown_timeout 30000;  # Set a 30 seconds timeout for worker shutdown

Setting a timeout too low can lead to active requests being terminated abnormally.

Not setting this directive can result in the default timeout being used, which may not suit all applications.

← Back to all directives