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 assudoer)
to check the existing values:To check Run command Value check Maximum number of open files per user login ulimit –Hn
If the returned value is less than 10240, run the commands in the step 3a. System-wide maximum number of open files sysctl fs.file-max
If the value returned is less than 100000, Run the commands in the step 3b TCP max sync backlog sysctl net.ipv4.tcp_max_syn_backlog
If the value returned is less than 5000, Run the commands in the step 3c. Read-ahead parameter blockdev ––getra /dev/sda
If 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:
Warning
Exercise caution when running the following commands. If the commands are not run correctly, the performance of the device may deteriorate and further impact the stability of the device.
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 10240
Save the file (:q) and run the following command to validate the changes:
# ulimit -Hn # ulimit -Sn
To set the system-wide maximum number of open files:
# vi /etc/sysctl.conf fs.file-max = 100000
Save the file (:q) and run the following command to validate the changes:
# sysctl -p
Run the following command to double-check:
# sysctl fs.file-max
To set the TCP maximum sync backlog:
# vi /etc/sysctl.conf net.ipv4.tcp_max_syn_backlog=5000
Save the file (:q) and run the following command to validate the changes:
# sysctl -p
Run the following command to double-check:
# sysctl net.ipv4.tcp_max_syn_backlog
To 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/sdc
Applying
noatime
attribute can also significantly improve the file I/O performance. To applynoatime
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.
Comments
Log in or register to comment.