【集锦压力测试】linux+nginx+php-fpm+mysql优化

【汇总压力测试】linux+nginx+php-fpm+mysql优化

====================== 压测前:

netstat -ntlp

ulimit -SHn 65535? (加入开机启动,nginx启动前)

检查优化:

nginx.conf

php-fpm.conf

my.cnf

?

优化/etc/sysctl.conf

增加:

?kernel.shmmax = 68719476736

?# Controls the maximum number of shared memory segments, in pages

?kernel.shmall = 4294967296

???

??????? #syncookie

??????? net.ipv4.tcp_max_syn_backlog = 65536

??????? net.core.netdev_max_backlog =? 32768

??????? net.core.somaxconn = 32768

??????? net.core.wmem_default = 8388608

??????? net.core.rmem_default = 8388608

??????? net.core.rmem_max = 16777216

??????? net.core.wmem_max = 16777216

??????? net.ipv4.tcp_timestamps = 0

??????? net.ipv4.tcp_synack_retries = 2

??????? net.ipv4.tcp_syn_retries = 2

??????? #time_wait

??????? net.ipv4.tcp_syncookies = 1

??????? net.ipv4.tcp_tw_recycle = 1

??????? net.ipv4.tcp_fin_timeout = 5

??????? net.ipv4.tcp_tw_reuse = 1

??????? net.ipv4.tcp_mem = 94500000 915000000 927000000

??????? net.ipv4.tcp_max_orphans = 3276800

??????? net.ipv4.ip_local_port_range = 1024? 65535

?

?

?

?

?

查看mysql连接

#netstat -anp | grep mysql | wc -l

netstat -n | awk ‘/^tcp/ {++state[$NF]} END {for(key in state) print key,”\t”,state[key]}’

查看TIME_WAIT连接数
netstat -ae|grep “TIME_WAIT” |wc -l

netstat -n | awk ‘/^tcp/ {++state[$NF]} END {for(key in state) print key,”\t”,state[key]}’

查找较多time_wait连接
netstat -n|grep TIME_WAIT|awk ‘{print $5}’|sort|uniq -c|sort -rn|head -n20

?

?

?

?

?

===================================实例测试

1

系统说明

服务器说明:

两台

CentOS release 5.4
(Final) 32

位,

1

CPU 8

?

a.??????

服务器

1

服务:

Nginx + php (fpm)

nginx

开启的进程数

8

FastCGI

进程数

128

?

b.??????

服务器

2

服务

:Memcache+mysql

memcache

替代

session

,开启两个端口,分别分配

1024M;

?

?

2)

模拟场景

:

首页,登录,退出

并发量:

900

?

?

?

===============

系统说明

?

#cat /etc/issue

CentOS release 5.4 (Final)

【集锦压力测试】linux+nginx+php-fpm+mysql优化

相关文章:

你感兴趣的文章:

标签云: