我用ab(ab -c50 -t5s)来testingApache V Nginx在同一台服务器上的静态文件。
Apache以每秒200个请求的速度处理CPU,而Nginx则处于CPU的25%左右,而手机每秒处理5211个请求。
Apache没有交换,缺乏内存不是问题。
我知道Nginx和Apache有很多不同的configuration,但是Apache的背后有多远,Nginx只是可笑而已。
事实上这很可笑,我想我已经错过了Apache的东西。
任何想法从哪里开始?
ab结果如下:
Server Software: nginx Server Port: 80 Document Path: /images/15.jpg Document Length: 15088 bytes Concurrency Level: 50 Time taken for tests: 5.494 seconds Complete requests: 26059 Failed requests: 0 Write errors: 0 Total transferred: 400370476 bytes HTML transferred: 393178192 bytes Requests per second: 5211.29 [#/sec] (mean) Time per request: 9.595 [ms] (mean) Time per request: 0.192 [ms] (mean, across all concurrent requests) Transfer rate: 78189.48 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 4 0.6 4 10 Processing: 3 5 0.8 5 13 Waiting: 0 2 1.3 2 10 Total: 6 9 0.9 9 19 Percentage of the requests served within a certain time (ms) 50% 9 66% 9 75% 9 80% 9 90% 10 95% 10 98% 11 99% 12 100% 19 (longest request) Server Software: Apache Server Port: 81 Document Path: /images/15.jpg Document Length: 15088 bytes Concurrency Level: 50 Time taken for tests: 5.31551 seconds Complete requests: 1008 Failed requests: 0 Write errors: 0 Total transferred: 15681815 bytes HTML transferred: 15433585 bytes Requests per second: 200.34 [#/sec] (mean) Time per request: 249.581 [ms] (mean) Time per request: 4.992 [ms] (mean, across all concurrent requests) Transfer rate: 3043.59 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 2 84 47.5 78 222 Processing: 24 158 46.5 162 260 Waiting: 1 96 45.1 91 221 Total: 187 242 48.5 232 428 Percentage of the requests served within a certain time (ms) 50% 232 66% 238 75% 246 80% 249 90% 304 95% 380 98% 409 99% 423 100% 428 (longest request)
这篇文章现在已经失效。
我发现这不是一个标准的Apache安装程序,扩展的mod_security规则是问题。