Linux TCP tuning
These are example Netflix TCP kernel parameters.
net.core.default_qdisc = fq
net.core.netdev_max_backlog = 5000
net.core.rmem_max = 16777216
net.core.somaxconn = 1024
net.core.wmem_max = 16777216
net.ipv4.ip_local_port_range = 10240 65535
net.ipv4.tcp_abort_on_overflow = 1
net.ipv4.tcp_congestion_control = bbr
net.ipv4.tcp_max_syn_backlog = 8192
net.ipv4.tcp_rmem = 4096 12582912 16777216
net.ipv4.tcp_slow_start_after_idle = 0
net.ipv4.tcp_syn_retries = 2
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_wmem = 4096 12582912 16777216
These are some examples I came up with for an apache2 site running moin via wsgi.
# WSGIDaemonProcess moin processes=12 threads=1 maximum-requests=5000 queue-timeout=20
net.core.somaxconn = 256 # observed max number of requests on the scoreboard
# consider being more aggressive with flaky connections
# try this first
#net.ipv4.tcp_slow_start_after_idle = 0
# aggressively reap flakey connections. avoid queue saturation from slow/flakey
# clients
#net.ipv4.tcp_fin_timeout = 5
#net.ipv4.tcp_syn_retries = 2
#net.ipv4.tcp_synack_retries = 2
# then maybe this
#net.ipv4.tcp_tw_reuse = 1 # this should only be enabled if we are seeing a high rate of time-wait connections
# needs further investigation, but potentially some of the below could be used
#net.core.rmem_max = 16777216
#net.core.wmem_max = 16777216
#net.ipv4.tcp_rmem = 4096 12582912 16777216
#net.ipv4.tcp_wmem = 4096 12582912 16777216
#net.ipv4.tcp_mem = 1638400 1638400 1638400
# /etc/systemd/system/apache2.service.d/prlimits.conf
#[Service]
#LimitNOFILE=
#LimitNOFILE=infinity