Middle+
Why does Nginx with 2 workers handling 2048 connections hit a limit at 3500, not 4096?
sobes.tech AI
Answer from AI
The reason is that the maximum number of connections that Nginx can handle is limited not only by the worker_connections parameter but also by system limits and architecture.
Main reasons why it is not possible to reach 4096 with 2 workers of 2048 connections:
- OS Limits: The maximum number of open files (ulimit -n) may be less than the product of worker_connections and the number of workers.
- Kernel resources: Kernel parameters such as net.core.somaxconn may limit the number of simultaneous connections.
- Additional descriptors: Each client can use multiple descriptors (e.g., for reading and writing), which reduces the total number of available connections.
- Internal Nginx limits: Some internal structures and buffers may limit the maximum number of active connections.
To increase the number of simultaneous connections, you need to check and raise system limits, configure kernel parameters, and ensure that the Nginx configuration matches these limits.