Skip to content

Commit bed2944

Browse files
committed
Increase net.core.somaxconn default to 2048
The default for Linux kernels 5.4+ is 4096. Changelog: performance
1 parent 06d9c19 commit bed2944

File tree

4 files changed

+25
-4
lines changed

4 files changed

+25
-4
lines changed

doc/troubleshooting.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ You may have to repeat this process for other lines. For example, reconfigure fa
351351
```plaintext
352352
kernel.shmall = 4194304
353353
kernel.sem = 250 32000 32 262
354-
net.core.somaxconn = 1024
354+
net.core.somaxconn = 2048
355355
kernel.shmmax = 17179869184
356356
```
357357

@@ -1020,3 +1020,24 @@ To resolve this issue, you have three options:
10201020
- If you cannot allowlist by domain, add the [CloudFront IP address ranges](https://d7uri8nf7uskq.cloudfront.net/tools/list-cloudfront-ips) to your firewall settings. You must
10211021
keep this list synced with your firewall settings because they can change.
10221022
- Manually download the package file and upload it to your server.
1023+
1024+
## Do I need to increase `net.core.somaxconn` ?
1025+
1026+
The following may assist in identifying if the value of `net.core.somaxconn`
1027+
is set too low:
1028+
1029+
```shell
1030+
$ netstat -ant | grep -c SYN_RECV
1031+
4
1032+
```
1033+
1034+
The return value from `netstat -ant | grep -c SYN_RECV` is the number of connections
1035+
waiting to be established. If the value is greater than `net.core.somaxconn`:
1036+
1037+
```shell
1038+
$ sysctl net.core.somaxconn
1039+
net.core.somaxconn = 1024
1040+
```
1041+
1042+
You may experience timeouts or HTTP 502 errors and is recommended to increase this
1043+
value by updating the `puma['somaxconn']` variable in your `gitlab.rb`.

files/gitlab-config-template/gitlab.rb.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1228,7 +1228,7 @@ external_url 'GENERATED_EXTERNAL_URL'
12281228
# puma['listen'] = '127.0.0.1'
12291229
# puma['port'] = 8080
12301230
# puma['socket'] = '/var/opt/gitlab/gitlab-rails/sockets/gitlab.socket'
1231-
# puma['somaxconn'] = 1024
1231+
# puma['somaxconn'] = 2048
12321232

12331233
### SSL settings
12341234
# puma['ssl_listen'] = nil

files/gitlab-cookbooks/gitlab/attributes/default.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@
678678
default['gitlab']['puma']['prometheus_scrape_tls_server_name'] = nil
679679
default['gitlab']['puma']['prometheus_scrape_tls_skip_verification'] = false
680680

681-
default['gitlab']['puma']['somaxconn'] = 1024
681+
default['gitlab']['puma']['somaxconn'] = 2048
682682
# Path to the puma server Process ID file
683683
# defaults to /opt/gitlab/var/puma/puma.pid. The install-dir path is set at build time
684684
default['gitlab']['puma']['pidfile'] = "#{node['package']['install-dir']}/var/puma/puma.pid"

spec/chef/cookbooks/gitlab/recipes/puma_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
end
8888

8989
it 'creates sysctl files' do
90-
expect(chef_run).to create_gitlab_sysctl('net.core.somaxconn').with_value(1024)
90+
expect(chef_run).to create_gitlab_sysctl('net.core.somaxconn').with_value(2048)
9191
end
9292
end
9393

0 commit comments

Comments
 (0)