Skip to content

Commit

Permalink
puppet: Decrease default nginx worker_connections.
Browse files Browse the repository at this point in the history
Increasing worker_connections has a memory cost, unlike the rest of
the changes in 1c76036; setting it to 1 million caused nginx to
consume several GB of memory.

Reduce the default down to 10k, and allow deploys to configure it up
if necessary.  `worker_rlimit_nofile` is left at 1M, since it has no
impact on memory consumption.
  • Loading branch information
alexmv authored and timabbott committed Mar 23, 2023
1 parent 12a61fc commit 262b193
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
10 changes: 10 additions & 0 deletions docs/production/deployment.md
Expand Up @@ -726,6 +726,16 @@ SSL/TLS termination.
Set to the port number if you [prefer to listen on a port other than
443](#using-an-alternate-port).

#### `nginx_worker_connections`

Adjust the [`worker_connections`][nginx_worker_connections] setting in
the nginx server. This defaults to 10000; increasing it allows more
concurrent connections per CPU core, at the cost of more memory
consumed by NGINX. This number, times the number of CPU cores, should
be more than twice the concurrent number of users.

[nginx_worker_connections]: http://nginx.org/en/docs/ngx_core_module.html#worker_connections

#### `queue_workers_multiprocess`

By default, Zulip automatically detects whether the system has enough
Expand Down
1 change: 1 addition & 0 deletions puppet/zulip/manifests/nginx.pp
Expand Up @@ -44,6 +44,7 @@
} else {
$ca_crt = '/etc/pki/tls/certs/ca-bundle.crt'
}
$worker_connections = zulipconf('application_server', 'nginx_worker_connections', 10000)
file { '/etc/nginx/nginx.conf':
ensure => file,
require => Package[$zulip::common::nginx, 'ca-certificates'],
Expand Down
2 changes: 1 addition & 1 deletion puppet/zulip/templates/nginx.conf.template.erb
Expand Up @@ -6,7 +6,7 @@ include /etc/nginx/modules-enabled/*.conf;

worker_rlimit_nofile 1000000;
events {
worker_connections 1000000;
worker_connections <%= @worker_connections %>;

use epoll;

Expand Down

0 comments on commit 262b193

Please sign in to comment.