wordpress服务器调优

最近弄了个网站,内存不大1GB

单核心CPU

然后跑centos有点费劲,所以换成了archlinux

安装完进行了内核调优和php调优,边调优边做了压力测试。

给大家分享一下结果,

  • nginx 1.12
  • php7.1.15
  • mariadb10

[root@news wrk]# ./wrk -t12 -c400 -d30s http://www.48hnews.com
Running 30s test @ http://www.48hnews.com
12 threads and 400 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 230.34ms 48.76ms 1.95s 98.18%
Req/Sec 95.98 27.85 210.00 72.33%
34070 requests in 30.04s, 30.86MB read
Socket errors: connect 0, read 0, write 0, timeout 386
Non-2xx or 3xx responses: 33664
Requests/sec: 1134.16
Transfer/sec: 1.03MB

调整多个php-fpm

[root@news wrk]# ./wrk -t12 -c400 -d30s http://www.48hnews.com
Running 30s test @ http://www.48hnews.com
12 threads and 400 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 274.86ms 201.24ms 1.91s 94.12%
Req/Sec 85.55 38.92 230.00 70.47%
28828 requests in 30.04s, 29.84MB read
Socket errors: connect 0, read 0, write 0, timeout 433
Non-2xx or 3xx responses: 28375
Requests/sec: 959.60
Transfer/sec: 0.99MB

开启superchache

[root@news wrk]# ./wrk -t12 -c400 -d30s http://www.48hnews.com
Running 30s test @ http://www.48hnews.com
12 threads and 400 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 303.20ms 141.30ms 1.94s 97.44%
Req/Sec 113.53 30.61 220.00 69.52%
40217 requests in 30.02s, 1.34GB read
Non-2xx or 3xx responses: 1301
Requests/sec: 1339.63
Transfer/sec: 45.59MB

修改文件打开数量ulimit -n 65535

[root@news wrk]# ./wrk -t12 -c400 -d30s http://www.48hnews.com
Running 30s test @ http://www.48hnews.com
12 threads and 400 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 301.91ms 153.14ms 2.00s 97.42%
Req/Sec 114.66 32.13 222.00 66.42%
40629 requests in 30.03s, 1.35GB read
Socket errors: connect 0, read 0, write 0, timeout 4
Non-2xx or 3xx responses: 1453
Requests/sec: 1352.99
Transfer/sec: 45.89MB

修改php-fpm进程数量25

[root@news wrk]# ./wrk -t12 -c400 -d30s http://www.48hnews.com
Running 30s test @ http://www.48hnews.com
12 threads and 400 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 275.92ms 39.35ms 1.99s 84.11%
Req/Sec 116.36 35.24 313.00 72.60%
41344 requests in 30.03s, 1.32GB read
Socket errors: connect 0, read 0, write 0, timeout 134
Non-2xx or 3xx responses: 2912
Requests/sec: 1376.56
Transfer/sec: 45.02MB

修改php-fpm进程数量30 nginx 进程数量 8

[root@news wrk]# ./wrk -t12 -c400 -d30s http://www.48hnews.com
Running 30s test @ http://www.48hnews.com
12 threads and 400 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 306.74ms 131.43ms 1.86s 97.17%
Req/Sec 111.62 32.40 250.00 73.84%
39558 requests in 30.02s, 1.36GB read
Non-2xx or 3xx responses: 62
Requests/sec: 1317.70
Transfer/sec: 46.26MB

修改php-fpm进程数量35

[root@news wrk]# ./wrk -t12 -c400 -d30s http://www.48hnews.com
Running 30s test @ http://www.48hnews.com
12 threads and 400 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 321.56ms 61.23ms 1.53s 92.08%
Req/Sec 104.09 33.37 270.00 64.64%
36799 requests in 30.03s, 1.26GB read
Non-2xx or 3xx responses: 137
Requests/sec: 1225.38
Transfer/sec: 42.93MB

修改文件描述符rlimit_files = 65535

pm.max_requests = 2048

[root@news wrk]# ./wrk -t12 -c400 -d30s http://www.48hnews.com
Running 30s test @ http://www.48hnews.com
12 threads and 400 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 299.33ms 62.05ms 1.15s 91.30%
Req/Sec 111.02 30.93 252.00 67.48%
39466 requests in 30.03s, 1.33GB read
Non-2xx or 3xx responses: 707
Requests/sec: 1314.35
Transfer/sec: 45.39MB

内核调优

net.core.rmem_default = 256960
net.core.rmem_max = 513920
net.core.wmem_default = 256960
net.core.wmem_max = 513920
net.core.netdev_max_backlog = 2000
net.core.somaxconn = 2048
net.core.optmem_max = 81920
net.ipv4.tcp_mem = 131072  262144  524288
net.ipv4.tcp_rmem = 8760  256960  4088000
net.ipv4.tcp_wmem = 8760  256960  4088000
net.ipv4.tcp_keepalive_time = 1800
net.ipv4.tcp_keepalive_intvl = 30
net.ipv4.tcp_keepalive_probes = 3
net.ipv4.tcp_sack = 1
net.ipv4.tcp_fack = 1
net.ipv4.tcp_timestamps = 1
net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_fin_timeout = 30
net.ipv4.ip_local_port_range = 1024  65000
net.ipv4.tcp_max_syn_backlog = 2048

[root@news wrk]# ./wrk -t12 -c400 -d30s http://www.48hnews.com
Running 30s test @ http://www.48hnews.com
12 threads and 400 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 305.94ms 33.13ms 872.89ms 86.39%
Req/Sec 108.25 29.24 260.00 71.87%
38500 requests in 30.02s, 1.31GB read
Non-2xx or 3xx responses: 274
Requests/sec: 1282.27
Transfer/sec: 44.75MB