Skip to content

Commit

Permalink
puppet: Increase backlogged socket count based on uwsgi backlog.
Browse files Browse the repository at this point in the history
Increasing the uwsgi listen backlog is intended to allow it to handle
higher connection rates during server restart, when many clients may
be trying to connect.  The kernel, in turn, needs to have a
proportionally increased somaxconn soas to not refuse the connection.

Set somaxconn to 2x the uwsgi backlog, but no lower than the
default (128).
  • Loading branch information
alexmv authored and timabbott committed Jul 29, 2020
1 parent 0e90442 commit ceb909d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
16 changes: 16 additions & 0 deletions puppet/zulip/manifests/app_frontend_base.pp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
$uwsgi_listen_backlog_limit = zulipconf('application_server', 'uwsgi_listen_backlog_limit', 128)
$uwsgi_buffer_size = zulipconf('application_server', 'uwsgi_buffer_size', 8192)
$uwsgi_processes = zulipconf('application_server', 'uwsgi_processes', $uwsgi_default_processes)
$somaxconn = 2 * $uwsgi_listen_backlog_limit
file { '/etc/zulip/uwsgi.ini':
ensure => file,
require => Package[supervisor],
Expand All @@ -105,6 +106,21 @@
content => template('zulip/uwsgi.ini.template.erb'),
notify => Service[$zulip::common::supervisor_service],
}
file { '/etc/sysctl.d/40-uwsgi.conf':
ensure => file,
owner => 'root',
group => 'root',
mode => '0644',
content => template('zulip/sysctl.d/40-uwsgi.conf.erb'),
}
exec { 'sysctl_p_uwsgi':
command => '/sbin/sysctl -p /etc/sysctl.d/40-uwsgi.conf',
subscribe => File['/etc/sysctl.d/40-uwsgi.conf'],
refreshonly => true,
# We have to protect against running in Docker and other
# containerization which prevents adjusting these.
onlyif => 'touch /proc/sys/net/core/somaxconn',
}

file { '/home/zulip/tornado':
ensure => directory,
Expand Down
2 changes: 2 additions & 0 deletions puppet/zulip/templates/sysctl.d/40-uwsgi.conf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Allow larger listen backlog
net.core.somaxconn=<%= [128, @somaxconn].max %>

0 comments on commit ceb909d

Please sign in to comment.