Linux Tuning — Swap, OOM Killer, Kernel
Linux tuning: memory, swap, kernel parameters
This service is for situations where a server behaves inexplicably: processes die for no apparent reason, the site intermittently returns errors, load spikes without a visible cause.
What I configure
- out-of-memory behaviour — which processes to protect and which can be sacrificed;
- swap: size and how eagerly the system reaches for it;
- limits on open files and processes;
- network parameters for servers handling many connections;
- I/O scheduler settings matched to the disk type;
- journald configuration, so logs do not consume the disk.
The most common reason people get in touch
Processes disappear without explanation. The site was working, then suddenly returned an error, and the logs are empty. Usually the system killed a process because memory ran out — and the database is the most frequent victim, because it holds the most.
The fix is not more swap, as is often suggested, but recalculating how much memory the web server and database actually consume together. It frequently turns out that the sum of their maximums exceeds physical memory — and the only question was when that would fire.
About expectations
Kernel tuning does not make a site twice as fast — it is not optimization, it is removing instability. If speed is the goal, performance optimization deals with different things.