Linux server settings for high-load systems
Introduction
Servers that handle a large number of simultaneous network connections require proper system tuning to ensure optimal performance and stability. By adjusting kernel parameters and system resource limits, Linux can efficiently manage a higher number of open files and network connections. This guide explains the key settings that should be configured for high-load systems.
Prerequisites
- Root or sudo access to the Linux server
- Basic knowledge of Linux system administration
- Access to modify system configuration files
Implementation
Configure fs. file-max
The fs.file-max kernel parameter defines the maximum number of file handles that the Linux kernel can allocate. Since each network connection consumes a file descriptor, this value should be set high enough to support the expected number of concurrent connections.
View the Current Value
sysctl fs.file-max
Example output:
fs.file-max = 358920
Update the Value
sysctl -w fs.file-max=360000
Example output:
fs.file-max = 360000
For high-load servers, it is recommended to configure this value to at least twice the expected number of concurrent network connections.
Configure net.ipv4.ip_local_port_range
This kernel parameter defines the range of local ports available for outbound network connections.
View the Current Value
sysctl net.ipv4.ip_local_port_range
Example output:
net.ipv4.ip_local_port_range = 32768 61000
Update the Port Range
sysctl -w net.ipv4.ip_local_port_range=”1024 65000″
Example output:
net.ipv4.ip_local_port_range = 1024 65000
This setting is particularly useful for proxy servers and applications that create a large number of outbound connections.
Make Kernel Changes Persistent
The above commands remain effective only until the next reboot.
To make the changes permanent, edit:
/etc/sysctl.conf
Add the following entries:
fs.file-max=360000
net.ipv4.ip_local_port_range=1024 65000
Reload the configuration without rebooting:
sysctl -p
This reloads the values from the /etc/sysctl.conf file.
Verify Current System Limits
The nofile limit specifies the maximum number of files that a user or process can open simultaneously.
View the current limits:
ulimit -a
To display the hard limits:
ulimit -a -H
Locate the open files value in the output.
Configure nofile limits.
Edit the limits configuration file:
/etc/security/limits.conf
To configure limits for a specific user:
jabber soft nofile 350000
jabber hard nofile 350000
Replace “jabber” with the username of the service account.
To apply the limits to all users:
- soft nofile 350000
- hard nofile 350000
After saving the file, log out and log back in for the changes to take effect.
Conclusion
Properly configuring kernel parameters, such as fs.file-max and the nofile system limits, helps Linux servers efficiently manage high volumes of network connections. These optimizations improve server performance, reduce resource exhaustion, and ensure greater stability under heavy workloads.
