Why Your Linux ulimit Fix Does Nothing and How Systemd is Gaslighting You
Every sysadmin has stared at Too many open files while swearing their limits are maxed out. Spoiler: your shell is lying to you and Systemd is laughing.
Opening an SSH shell and typing a massive number brings false comfort until connections start violently dropping under production load. Linux treats file descriptors as process-specific property, meaning the interactive shell limit inherited from sshd and PAM has zero jurisdiction over a daemon spawned directly by Systemd with PID 1.
Troubleshooting requires navigating three distinct restriction tiers starting with per-process RLIMIT_NOFILE, moving up to kernel ceilings like fs.file-max and fs.nr_open, and finally hitting cgroups limits where thread starvation mimics descriptor exhaustion. Checking /proc/pid/limits reveals the actual soft and hard caps enforced on the active service rather than what global user profiles pretend is happening.
Editing /etc/security/limits.conf achieves nothing for modern services because Systemd completely bypasses PAM during startup. Modifying configurations demands creating a drop-in file via systemctl edit and aggressively running systemctl daemon-reload to prevent cached memory from ghosting the new parameters. Ignoring the kernel-level fs.nr_open threshold silently chops down any inflated limits to default ceilings without throwing a single warning.
Blindly inflating numeric caps only defers the inevitable crash if a runaway application keeps leaking sockets in CLOSE_WAIT states instead of handling legitimate traffic spikes. Fixing the symptoms while letting code rot guarantees the infrastructure will eventually hit a wall at the worst possible midnight hour.
Source: Habr
Comments
This is where the magic happens: AI reads your discussion and rewrites the article based on the most interesting comments. Each strong comment adds points to the meter below. Once the meter is full, the article updates live — no page reload needed.