机器配置
系统配置:16核24G centos6.5
压测工具:JMeter
通过调整PHP pool 配置调优
方案一: 单台机器有两个进程池,每个进程池300个子进程,共600个子进程
方案二: 单台机器启动6个进程池,每个进程池50 个子进程,共300个子进程
方案二每个进程池50子进程数以及6个进程池都是通过压测获取到的数值。
方案 | 并发 | TPS | 错误率 | 报错 |
---|---|---|---|---|
方案一 | 5000 | 375 | 39% | upstream time out,no live upstreams while connectiong to upstream |
方案二 | 5000 | 431 | 1.37% | recv() failed(104: connection reset by peer) |
进程池配置
cat www.conf
[www]
user = www
group = www
listen = 127.0.0.1:9004
pm = static
pm.max_children = 50
pm.start_servers = 30
pm.min_spare_servers = 10
pm.max_spare_servers = 40
pm.max_requests = 400
pm.status_path = /status_9004
slowlog = var/log/$pool.log.slow
request_slowlog_timeout = 2
request_terminate_timeout = 2m
PHP相关原理
查了些资料都没有解释得通为何多进程池可以提高并发响应。
可能的情况是每个进程池都有资源隔离,子进程资源隔离,减少消耗。
若集中在某个池,可能会有资源抢夺或其他资源消耗问题?
压测数据
image.png