Calculate recommended sysctl kernel parameter values for a given workload profile.
sysctl parameters tune kernel subsystem behavior at runtime without a reboot. vm.swappiness (0-100) biases the kernel's memory reclaim between swapping out anonymous pages versus reclaiming page cache — lower values favor keeping processes in RAM (better for databases), higher values favor keeping more page cache. net.core.somaxconn caps the accept() backlog queue depth for listening sockets — set too low relative to incoming connection rate, a burst of new connections can overflow the backlog and get refused even though the application itself has spare capacity. fs.file-max caps total open file descriptors system-wide, relevant for high-concurrency servers.
Backlog headroom
backlog_headroom = somaxconn − expected_connections_per_sec
`sysctl vm.swappiness` reads the current value; `sudo sysctl -w vm.swappiness=10` changes it immediately but only until reboot. To persist, add `vm.swappiness = 10` to /etc/sysctl.conf or a file under /etc/sysctl.d/ and run `sudo sysctl -p`.
Not necessarily — the application's own listen() call passes a backlog argument that is capped by (effectively min'd with) somaxconn; many servers (nginx, e.g. via its `backlog` directive) need their own configuration raised to actually use a higher kernel-level somaxconn.
Values of 1-10 are common recommendations for PostgreSQL/MySQL hosts to minimize the risk of swap-induced query latency spikes, since databases typically manage their own buffer caching and benefit more from staying resident in RAM than from the kernel's generic page cache heuristics.