System parameter tuning for performance stress testing under Linux

1 Introduction

When doing server-side pressure testing, we often encounter some situations where the pressure cannot go up due to Linux system limitations. Here we do some tuning on the Linux system parameters to reduce the interference of such factors.

2. Configuration

2.1 Linux system configuration

Execute : sudo vi /etc/sysctl.conf, add the following content:

net.ipv4.tcp_syncookies = 0
fs.file-max = 12553500
fs.nr_open = 12453500
kernel.shmall= 1048576
kernel.shmmax = 1887436
kernel.msgmax = 65536
kernel.sysrq = 0
kernel.pid_max= 65536
net.core.netdev_max_backlog = 2000000
net.core.rmem_default = 699040
net.core.rmem_max = 50331648
net.core.wmem_default = 131072
net.core.wmem_max = 33554432
net.core.somaxconn = 65535
net.ipv4.ip_nonlocal_bind = 1
net.ipv4.tcp_max_orphans = 3276800
net.ipv4.tcp_mem = 1048576 1572864 2097152
net.ipv4.tcp_rmem = 4096 4194304 8388608
net.ipv4.tcp_wmem = 4096 4194304 8388608
net.ipv4.tcp_slow_start_after_idle = 0
net.ipv4.tcp_synack_retries = 1
net.ipv4.tcp_window_scaling = 1
vm.swappiness = 0

#TCP connection recovery
net.ipv4.tcp_max_tw_buckets = 6000000
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_fin_timeout = 10
net.ipv4.route.max_size = 5242880
net.ipv4.ip_forward = 1
net. ipv4.tcp_timestamps = 1 #Enable
support for TCP timestamps. If this item is set to 0, the following setting will not work

#TCP connection manager
net.ipv4.tcp_max_syn_backlog = 655360
net.ipv4.tcp_syn_retries = 6
net.ipv4.tcp_retries1 = 3
net.ipv4.tcp_retries2 = 6

#TCP keepalive
net.ipv4.ip_local_port_range = 1000 65534
net.ipv4.tcp_keepalive_time = 30
net.ipv4.tcp_keepalive_intvl = 30
net.ipv4.tcp_keepalive_probes = 3
fs.inotify.max_user_watches=524288

Execute after saving: sysctl -p  takes effect.

2.2 File descriptor limits

2.2.1 Modify the configuration of fileno

Execute: sudo vi /etc/security/limits.conf,  add at the end of the article:

- nofile 1000000

2.2.2 Modify the supervisor service configuration file (if it is a program started by the supervisor, you can modify it here)

Execute: vi /usr/lib/systemd/system/supervisord.service, add the following:

 [Service]

#Add the following three lines

LimitCORE=infinity

LimitNOFILE = 1000000

LimitNPROC = 1000000

 

After modifying the above supervisord.service, execute the following command to take effect

sudo systemctl daemon-reload
sudo systemctl restart supervisord.service

2.2.3 Verify that the open files are modified successfully

1. Global View

Execute: ulimit -a , view the open files option

2. View the number of open files for the supervisor to start the service

#1. Query the pid of the supervisor first
ps aux | grep supervisor
#2. If it is 22296, check the process limit
cat /proc/22296/limits
#3. It's ok to see the following line
Max open files 1000000 1000000 files

2.3 /etc/security/limits.conf configuration 

limits.conf is the Linux resource limit configuration file. For performance testing, we can increase it

* soft nofile 655350   
* hard nofile 655350
* soft nproc  655350   
* hard nproc  650000

After the above configuration, when we use stress testing tools such as Jmeter to perform stress testing, the back-end services can enjoy the maximum performance of the Linux software level.

Portal: 2021 latest test data & major factory positions

Blogger: test to make money (a test open code farmer who is not 996 but 996)

Motto: Focus on test development and automated operation and maintenance, work hard to read, think and write, and lay financial freedom for the life of the internal volume.

Content categories: technology improvement, workplace miscellaneous talk, career development, reading and writing, investment and financial management, healthy life.

csdn:https://blog.csdn.net/ccgshigao

Blog Park: https://www.cnblogs.com/qa-freeroad/

51cto :https://blog.51cto.com/14900374

WeChat public account : test to make money (share exclusive content and resources regularly)


Guess you like

Origin blog.51cto.com/14900374/2663696