Linux下性能压测之系统参数调优
生活随笔
收集整理的這篇文章主要介紹了
Linux下性能压测之系统参数调优
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1. 前言
在做服務端壓測的時候,經常會遇到一些由于Linux系統限制導致壓力上不去的情況,這里從Linux系統參數上做一些調優,減少此類因素的干擾。
2. 配置
2.1 Linux系統配置
執行:sudo vi /etc/sysctl.conf,添加以下內容:
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 #開啟對于TCP時間戳的支持,若該項設置為0,則下面一項設置不起作用#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保存后執行:sysctl -p?生效。
2.2 文件描述符限制
2.2.1 修改fileno的配置
執行:sudo? vi /etc/security/limits.conf ,?文末添加:
- nofile 1000000
2.2.2 修改supervisor服務配置文件(如果是supervisor啟動的程序,則可以修改此處)
執行:vi /usr/lib/systemd/system/supervisord.service,添加如下:
?[Service]
#添加如下三行
LimitCORE=infinity
LimitNOFILE=1000000
LimitNPROC=1000000
?
修改完上述supervisord.service后,執行如下命令生效
sudo systemctl daemon-reload sudo systemctl restart supervisord.service2.2.3 驗證open files是否修改成功
1. 全局查看
執行:ulimit -a,查看open files選項
2. 查看supervisor啟動服務的open files數
#1. 先查詢supervisor的pid ps aux |grep supervisor #2. 假如是22296,查看進程限制 cat /proc/22296/limits #3. 看到有下面一行就ok了 Max open files 1000000 1000000 files2.3 /etc/security/limits.conf配置?
limits.conf是Linux資源限制配置文件,為了性能測試,我們可以將其調大
* soft nofile 655350 * hard nofile 655350 * soft nproc 655350 * hard nproc 650000進行了如上配置之后,在我們使用Jmeter等壓測工具進行壓測的時候,后端服務能享受到Linux軟件層面的最大性能。
總結
以上是生活随笔為你收集整理的Linux下性能压测之系统参数调优的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 压力测试时候Linux系统参数的调优
- 下一篇: xshell6保持连接_使用Xshell