在把源安装调整成和编译安装一样的 PHP 设置(进程数和 CPU 核数相同)之后,结果变成了源安装比编译安装略好
PHP 配置:
pm = dynamic
pm.max_children = 4
pm.start_servers = 2
pm.min_spare_servers = 2
pm.max_spare_servers = 4
pm.process_idle_timeout = 10s
pm.max_requests = 2048
rlimit_files = 51200
rlimit_core = 0
结果:
This is ApacheBench, Version 2.3 <$Revision: 1604373 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd,
http://www.zeustech.net/Licensed to The Apache Software Foundation,
http://www.apache.org/Benchmarking x.x.x.167 (be patient)
Server Software: nginx/1.8.1
Server Hostname: x.x.x.167
Server Port: 80
Document Path: /?paged=2
Document Length: 48526 bytes
Concurrency Level: 50
Time taken for tests: 6568.194 seconds
Complete requests: 25000
Failed requests: 0
Total transferred: 1218625000 bytes
HTML transferred: 1213150000 bytes
Requests per second: 3.81 [#/sec] (mean)
Time per request: 13136.388 [ms] (mean)
Time per request: 262.728 [ms] (mean, across all concurrent requests)
Transfer rate: 181.19 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.1 0 3
Processing: 1030 13123 514.0 13130 17304
Waiting: 158 12224 499.5 12236 15666
Total: 1033 13123 514.0 13130 17304
Percentage of the requests served within a certain time (ms)
50% 13130
66% 13209
75% 13258
80% 13289
90% 13381
95% 13508
98% 14403
99% 15127
100% 17304 (longest request)
所以目前的结论是: php-fpm 的 max_children 要设置成和 CPU 核心数(逻辑核心 /进程数)相同