2014-04-15 13:33:01
来 源
IT技术网
Nginx
本文介绍Apache2.4.1与Nginx-1.0.12性能测试对比,希望对于初学Nginx服务器相关的朋友有帮助,更多Nginx安装、配置、报错处理等资源请本站内搜索。。
apache2.4.1放出后据说性能目标直指nginx,所以自己编译安装了两个版本进行静态页的压力测试。

测试服务器为虚拟机 2颗CPU 2G内存。

编译选项:

apache:

./configure –prefix=/usr/local/apache –enable-proxy-http –enable-proxy-fcgi –enable-proxy –enable-proxy-connect –enable-proxy-ftp –with-apr=/usr/local/apr –with-apr-util=/usr/local/apr-util/

nginx:

./configure –prefix=/usr/local/nginx

相邻机ab压同一静态页

[[email protected] ~]# curl http://192.168.2.129/index.html

test for apache 2.4

数据:

apache:

[[email protected] ~]# ab -n 1000000 -c 100 http://192.168.2.129/index.html

This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0

Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/

Copyright 2006 The Apache Software Foundation, http://www.apache.org/

Benchmarking 192.168.2.129 (be patient)

Completed 100000 requests

Completed 200000 requests

Completed 300000 requests

Completed 400000 requests

Completed 500000 requests

Completed 600000 requests

Completed 700000 requests

Completed 800000 requests

Completed 900000 requests

Finished 1000000 requests

Server Software: Apache/2.4.1

Server Hostname: 192.168.2.129

Server Port: 80

Document Path: /index.html

Document Length: 20 bytes

Concurrency Level: 100

Time taken for tests: 132.517663 seconds

Complete requests: 1000000

Failed requests: 0

Write errors: 0

Total transferred: 263000000 bytes

HTML transferred: 20000000 bytes

Requests per second: 7546.16 [#/sec] (mean)

Time per request: 13.252 [ms] (mean)

Time per request: 0.133 [ms] (mean, across all concurrent requests)

Transfer rate: 1938.12 [Kbytes/sec] received

Connection Times (ms)

min mean[+/-sd] median max

Connect: 0 1 59.3 0 3001

Processing: 0 11 16.8 5 687

Waiting: 0 7 11.1 2 630

Total: 0 12 61.7 5 3067

Percentage of the requests served within a certain time (ms)

50% 5

66% 14

75% 19

80% 23

90% 32

95% 40

98% 49

99% 57

100% 3067 (longest request)

nginx:

[[email protected] ~]# ab -n 1000000 -c 100 http://192.168.2.129/index.html

This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0

Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/

Copyright 2006 The Apache Software Foundation, http://www.apache.org/

Benchmarking 192.168.2.129 (be patient)

Completed 100000 requests

Completed 200000 requests

Completed 300000 requests

Completed 400000 requests

Completed 500000 requests

Completed 600000 requests

Completed 700000 requests

Completed 800000 requests

Completed 900000 requests

Finished 1000000 requests

Server Software: nginx/1.0.12

Server Hostname: 192.168.2.129

Server Port: 80

Document Path: /index.html

Document Length: 20 bytes

Concurrency Level: 100

Time taken for tests: 110.121829 seconds

Complete requests: 1000000

Failed requests: 0

Write errors: 0

Total transferred: 230000230 bytes

HTML transferred: 20000020 bytes

Requests per second: 9080.85 [#/sec] (mean)

Time per request: 11.012 [ms] (mean)

Time per request: 0.110 [ms] (mean, across all concurrent requests)

Transfer rate: 2039.64 [Kbytes/sec] received

Connection Times (ms)

min mean[+/-sd] median max

Connect: 0 1 59.9 0 3005

Processing: 0 9 7.9 9 649

Waiting: 0 8 6.5 9 647

Total: 1 10 60.4 9 3016

Percentage of the requests served within a certain time (ms)

50% 9

66% 10

75% 11

80% 11

90% 11

95% 11

98% 11

99% 12

100% 3016 (longest request)

apache的Requests per second达到了7546.16 [#/sec] 而nginx则更胜一筹有9080.85 [#/sec]

其中在apache跑的过程中服务器的负载load 1分钟一度达到了load average: 83.66左右,而nginx则持续在1.5左右,httpd仍然不能算是能和nginx媲美

声明: 此文观点不代表本站立场;转载须要保留原文链接;版权疑问请联系我们。