Stop your server from ignoring half your available file handles

Performance Tuning & Kernel Parameters (Sysctl)

Stop your server from ignoring half your available file handles

🧩 The Challenge

Dealing with a production app that randomly craps out with “Too many open files” errors even though your ulimits look fine is enough to make anyone lose their mind. You checked the application configuration, bumped the soft limits, and yet the server still acts like it’s hit a wall.

💡 The Fix

The kernel has its own global file-max cap that sits above your user-level ulimits and often defaults to values that are way too small for modern high-concurrency workloads. Bumping this ensures the OS actually lets the application use the file descriptors it asked for.

sysctl -w fs.file-max=2097152
echo "fs.file-max=2097152" >> /etc/sysctl.conf
sysctl -p

⚙️ Why It Works

Setting this value directly tells the kernel how many total file handles the entire system is allowed to keep open at once. Since the default is often calculated based on RAM size years ago, it usually needs a significant push to accommodate modern web servers or database clusters.

🚀 Pro-Tip: Run cat /proc/sys/fs/file-nr to see exactly how many descriptors you’re using right now before you decide on a new limit.

Linux Tips & Tricks | © ngelinux.com | 9/19/2026

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted