sysctl settings for robustly handling tons of users
Edit /etc/sysctl.d/99-custom.conf
# max memory that sockets may request
net.core.rmem_max = 33554432
net.core.wmem_max = 33554432
# default memory allocated to sockets
# this won't actually use 16mb per socket, memory will be allocated as needed
# saves you from needing to call setsockopt in software
net.core.rmem_default = 16777216
net.core.wmem_default = 16777216
# how many packets the nic may buffer before dropping if the kernel can't process them
net.core.netdev_max_backlog = 20000
# ensure syn cookies are enabled to protect against syn floods
net.ipv4.tcp_syncookies = 1
# reduce number of synack retries
net.ipv4.tcp_synack_retries = 2
# max size of the listen queue, you want the file limit be way bigger than these two
# in case of a flood, syn cookies will initiate long before you run out of files
net.ipv4.tcp_max_syn_backlog = 2048
net.core.somaxconn = 2048
Reload the sysctls to apply them
sudo systemctl restart systemd-sysctl