Best practices for masters and relays deployed on Linux
The most common cause for deteriorated performance (with frequent crash) of masters and relays on Linux is because the default values set for descriptors are very low. The following configuration checks help you improve the performance (and avoid crashes) of masters and relays on a Linux platform:
- Connect to the device locally and launch the terminal
OR
Connect to the device using SSH. Run the following commands as root (or as sudoer) to check the existing values:
To check
Run command
Value check
Maximum number of open files per user login
ulimit –HnIf the returned value is less than 10240, run the commands in the step 3a.
System-wide maximum number of open files
sysctl fs.file-maxIf the value returned is less than 100000, Run the commands in the step 3b
TCP max sync backlog
sysctl net.ipv4.tcp_max_syn_backlogIf the value returned is less than 5000, Run the commands in the step 3c.
Read-ahead parameter
blockdev –getra /dev/sdaIf the value returned is less than 4096, run the commands in the step 3d.
Depending on the returned values in step 2, run the following commands:
To set the maximum number of open file descriptors per user login (value returned by the ulimit-HnRun command):
# vi /etc/security/limits.conf
root soft nofile 4096
root hard nofile 10240Save the file (:q) and run the following command to validate the changes:
# ulimit -Hn
# ulimit -SnTo set the system-wide maximum number of open files:
# vi /etc/sysctl.conf
fs.file-max = 100000Save the file (:q) and run the following command to validate the changes:
# sysctl -pRun the following command to double-check:
# sysctl fs.file-maxTo set the TCP maximum sync backlog:
# vi /etc/sysctl.conf
net.ipv4.tcp_max_syn_backlog=5000Save the file (:q) and run the following command to validate the changes:
# sysctl -pRun the following command to double-check:
# sysctl net.ipv4.tcp_max_syn_backlogTo set the Read-Ahead value to 4096 for each /dev/sd drive on your server, edit the /etc/rc.local file and add the following block at the end of the file (this is an example of a server with three drive entries - a, b, and c):
blockdev --setra 4096 /dev/sda
blockdev --setra 4096 /dev/sdb
blockdev --setra 4096 /dev/sdcApplying noatime attribute can also significantly improve the file I/O performance. To apply noatime attribute by editing the /etc/fstab file and replacing the 'defaults' with 'defaults,noatime', run the following command:
# /etc/fstab
/dev/mapper/centos-root / xfs defaults,noatime 0 0
UUID=a8f64424-1a43-4735-a20e-54a8f43304fe /boot xfs defaults,noatime 0 0
/dev/mapper/centos-home /home xfs defaults,noatime 0 0
/dev/mapper/centos-swap swap swap defaults,noatime 0 0
- Reboot the device.