我几个月前从Apache切换到Nginx / PHP-FPM。
我在一个drupal网站上做了一些基准测试,并测试了几个用例。在具有1个CPU和512 Mo RAM的VPS服务器上
仅缓存的Drupal
Nginx的
ab -n 100 -c 30 xxx
Server Software: nginx
Document Path: /
Document Length: 24902 bytes
Concurrency Level: 30
Time taken for tests: 2.775 seconds
Complete requests: 100
Failed requests: 0
Write errors: 0
Total transferred: 2529500 bytes
HTML transferred: 2490200 bytes
Requests per second: 36.04 [#/sec] (mean)
Time per request: 832.394 [ms] (mean)
Time per request: 27.746 [ms] (mean, across all concurrent requests)
Transfer rate: 890.28 [Kbytes/sec] received
httperf --client=0/1 --server=xxx --port=80 --uri=/ --send-buffer=4096 --recv-buffer=16384 --num-conns=100 --num-calls=10
Maximum connect burst length: 1
Total: connections 100 requests 1000 replies 1000 test-duration 48.946 s
Connection rate: 2.0 conn/s (489.5 ms/conn, <=1 concurrent connections)
Connection time [ms]: min 470.6 avg 489.5 max 522.2 median 488.5 stddev 9.5
Connection time [ms]: connect 0.2
Connection length [replies/conn]: 10.000
Request rate: 20.4 req/s (48.9 ms/req)
Request size [B]: 74.0
Reply rate [replies/s]: min 20.0 avg 20.4 max 20.8 stddev 0.2 (9 samples)
Reply time [ms]: response 46.8 transfer 2.1
Reply size [B]: header 450.0 content 24902.0 footer 2.0 (total 25354.0)
Reply status: 1xx=0 2xx=1000 3xx=0 4xx=0 5xx=0
CPU time [s]: user 6.50 system 17.58 (user 13.3% system 35.9% total 49.2%)
Net I/O: 507.3 KB/s (4.2*10^6 bps)
阿帕奇
ab -n 100 -c 30 xxx
Server Software: Apache/2.2.16
Document Path: /
Document Length: 24902 bytes
Concurrency Level: 30
Time taken for tests: 28.364 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 25346000 bytes
HTML transferred: 24902000 bytes
Requests per second: 35.26 [#/sec] (mean)
Time per request: 850.918 [ms] (mean)
Time per request: 28.364 [ms] (mean, across all concurrent requests)
Transfer rate: 872.66 [Kbytes/sec] received
httperf --client=0/1 --server=xxx --port=80 --uri=/ --send-buffer=4096 --recv-buffer=16384 --num-conns=100 --num-calls=10
Maximum connect burst length: 1
Total: connections 100 requests 1000 replies 1000 test-duration 52.261 s
Connection rate: 1.9 conn/s (522.6 ms/conn, <=1 concurrent connections)
Connection time [ms]: min 499.0 avg 522.6 max 591.0 median 518.5 stddev 19.4
Connection time [ms]: connect 0.6
Connection length [replies/conn]: 10.000
Request rate: 19.1 req/s (52.3 ms/req)
Request size [B]: 74.0
Reply rate [replies/s]: min 18.2 avg 19.2 max 19.6 stddev 0.5 (10 samples)
Reply time [ms]: response 46.9 transfer 5.3
Reply size [B]: header 453.0 content 24902.0 footer 2.0 (total 25357.0)
Reply status: 1xx=0 2xx=1000 3xx=0 4xx=0 5xx=0
CPU time [s]: user 6.80 system 18.88 (user 13.0% system 36.1% total 49.1%)
Net I/O: 475.2 KB/s (3.9*10^6 bps)
Errors: total 0 client-timo 0 socket-timo 0 connrefused 0 connreset 0
Errors: fd-unavail 0 addrunavail 0 ftab-full 0 other 0
具有缓存和增强功能的Drupal
Nginx的
ab -n 10000 -c 30 xxx
Server Software: nginx
Document Path: /
Document Length: 25002 bytes
Concurrency Level: 30
Time taken for tests: 2.275 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Total transferred: 253780000 bytes
HTML transferred: 250020000 bytes
Requests per second: 4395.52 [#/sec] (mean)
Time per request: 6.825 [ms] (mean)
Time per request: 0.228 [ms] (mean, across all concurrent requests)
Transfer rate: 108934.95 [Kbytes/sec] received
httperf --client=0/1 --server=xxx --port=80 --uri=/ --send-buffer=4096 --recv-buffer=16384 --num-conns=1000 --num-calls=30
Maximum connect burst length: 1
Total: connections 1000 requests 30000 replies 30000 test-duration 5.971 s
Connection rate: 167.5 conn/s (6.0 ms/conn, <=1 concurrent connections)
Connection time [ms]: min 4.2 avg 6.0 max 13.0 median 4.5 stddev 2.6
Connection time [ms]: connect 0.1
Connection length [replies/conn]: 30.000
Request rate: 5024.0 req/s (0.2 ms/req)
Request size [B]: 74.0
Reply rate [replies/s]: min 5017.2 avg 5017.2 max 5017.2 stddev 0.0 (1 samples)
Reply time [ms]: response 0.2 transfer 0.0
Reply size [B]: header 405.0 content 25002.0 footer 0.0 (total 25407.0)
Reply status: 1xx=0 2xx=30000 3xx=0 4xx=0 5xx=0
CPU time [s]: user 0.79 system 2.56 (user 13.2% system 42.9% total 56.1%)
Net I/O: 125016.7 KB/s (1024.1*10^6 bps)
Errors: total 0 client-timo 0 socket-timo 0 connrefused 0 connreset 0
Errors: fd-unavail 0 addrunavail 0 ftab-full 0 other 0
阿帕奇
ab -n 1000 -c 30 xxxx
Server Software: Apache/2.2.16
Document Path: /
Document Length: 25002 bytes
Concurrency Level: 30
Time taken for tests: 0.753 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 25291000 bytes
HTML transferred: 25002000 bytes
Requests per second: 1327.92 [#/sec] (mean)
Time per request: 22.592 [ms] (mean)
Time per request: 0.753 [ms] (mean, across all concurrent requests)
Transfer rate: 32797.26 [Kbytes/sec] received
httperf --client=0/1 --server=xxx --port=80 --uri=/ --send-buffer=4096 --recv-buffer=16384 --num-conns=100 --num-calls=10
Maximum connect burst length: 1
Total: connections 100 requests 1000 replies 1000 test-duration 1.148 s
Connection rate: 87.1 conn/s (11.5 ms/conn, <=1 concurrent connections)
Connection time [ms]: min 6.2 avg 11.5 max 14.1 median 11.5 stddev 1.3
Connection time [ms]: connect 0.1
Connection length [replies/conn]: 10.000
Request rate: 870.8 req/s (1.1 ms/req)
Request size [B]: 74.0
Reply rate [replies/s]: min 0.0 avg 0.0 max 0.0 stddev 0.0 (0 samples)
Reply time [ms]: response 1.1 transfer 0.1
Reply size [B]: header 260.0 content 25002.0 footer 0.0 (total 25262.0)
Reply status: 1xx=0 2xx=1000 3xx=0 4xx=0 5xx=0
CPU time [s]: user 0.13 system 0.57 (user 11.1% system 49.5% total 60.6%)
Net I/O: 21544.9 KB/s (176.5*10^6 bps)
Errors: total 0 client-timo 0 socket-timo 0 connrefused 0 connreset 0
Errors: fd-unavail 0 addrunavail 0 ftab-full 0 other 0
认证用户的基准(页面加载)
Nginx的
Page load times : 2.85 s
阿帕奇
Page load times : 5.4 s
但是Nginx的强大之处在于缓存系统
不启用Boost和Nginx且启用了缓存系统的Drupal
Server Software: nginx
Document Path: /
Document Length: 24902 bytes
Concurrency Level: 30
Time taken for tests: 2.437 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Total transferred: 252670000 bytes
HTML transferred: 249020000 bytes
Requests per second: 4103.34 [#/sec] (mean)
Time per request: 7.311 [ms] (mean)
Time per request: 0.244 [ms] (mean, across all concurrent requests)
Transfer rate: 101248.99 [Kbytes/sec] received
httperf --client=0/1 --server=xxx --port=80 --uri=/ --send-buffer=4096 --recv-buffer=16384 --num-conns=1000 --num-calls=30
Maximum connect burst length: 1
Total: connections 1000 requests 30000 replies 30000 test-duration 6.044 s
Connection rate: 165.5 conn/s (6.0 ms/conn, <=1 concurrent connections)
Connection time [ms]: min 4.2 avg 6.0 max 11.7 median 4.5 stddev 2.6
Connection time [ms]: connect 0.1
Connection length [replies/conn]: 30.000
Request rate: 4963.7 req/s (0.2 ms/req)
Request size [B]: 74.0
Reply rate [replies/s]: min 4970.1 avg 4970.1 max 4970.1 stddev 0.0 (1 samples)
Reply time [ms]: response 0.2 transfer 0.0
Reply size [B]: header 405.0 content 25002.0 footer 0.0 (total 25407.0)
Reply status: 1xx=0 2xx=30000 3xx=0 4xx=0 5xx=0
CPU time [s]: user 0.72 system 2.68 (user 12.0% system 44.3% total 56.3%)
Net I/O: 123516.8 KB/s (1011.8*10^6 bps)
Errors: total 0 client-timo 0 socket-timo 0 connrefused 0 connreset 0
Errors: fd-unavail 0 addrunavail 0 ftab-full 0 other 0
您应该将perusio的配置 Nginx用于Drupal