Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Optimal value for Nginx worker_connections

Nginx worker_connections sets the maximum number of simultaneous connections that can be opened by a worker process. This number includes all connections (e.g. connections with proxied servers, among others), not only connections with clients. Another consideration is that the actual number of simultaneous connections cannot exceed the current limit on the maximum number of open files. I have few queries around this:

  1. What should be the optimal or recommended value for this?
  2. What are the downsides of using a high number of worker connections?
like image 954
Aarti Avatar asked Nov 14 '25 11:11

Aarti


1 Answers

Setting lower limits may be useful when you may be resource-constrained. Some connections, for example, keep-alive connections, are effectively wasting your resources (even if nginx is very efficient, which it is), and aren't required for correct operation of a general-purpose server.

Having a lower resource limit will indicate to nginx that you are low on physical resources, and those available should be allocated to new connections, rather than to serve the idling keep-alive connections.

What is the recommended value? It's the default.

The defaults are all documented within the documentation:

Default: worker_connections 512;

And can be confirmed in the source-code at event/ngx_event.c, too

13#define DEFAULT_CONNECTIONS 512

like image 149
cnst Avatar answered Nov 17 '25 09:11

cnst



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!