Why Is My Server Overloaded?
Default Linux installations often have resource limits (ulimits) and kernel parameters configured for general use, not for high-throughput media streaming. When these limits are reached, your server may struggle with open files, network connections, and processes, leading to high CPU/RAM usage and buffering.
1Step 1: Increase System Limits (ulimit)
First, check your current user limits. Run ulimit -u. If it returns a low number like 1024, you need to increase it.
Edit the security limits configuration file:
Scroll to the end of the file and paste the following lines to drastically increase the limit on open files and processes:
Save and close the file (Ctrl+X, then Y).
2Step 2: Optimize Kernel Parameters (sysctl)
Next, we need to tune the kernel's networking stack to handle more connections and data throughput.
Edit the sysctl configuration file:
Add the following optimized settings to the end of the file:
Apply these changes immediately by running:
3Step 3: Verification & Reboot
To ensure all settings are applied correctly, it is highly recommended to reboot your server.
After the server comes back online, verify the changes:
- Run
ulimit -u. It should now show 500000. - Run
sudo sysctl -pagain to confirm the network settings are loaded without errors.
Troubleshooting
If you encounter an error regarding nf_conntrack while applying sysctl settings, it means the module isn't loaded. Fix it by running:
Then run sudo sysctl -p again.
