ApacheBench来自网络上另一个系统的结果为nginx,php-fpm

时间:2012-03-08 12:41:23

标签: php zend-framework nginx apachebench yaf

我有一个相当奇怪的问题,并且考虑到我对这一切都很陌生,这可能只是一个愚蠢的时刻。寻找关于我可能做错的建议 -

背景 - 我正在使用nginx和php-fpm来服务我的Zend / Yaf应用程序。 我使用Zend Framework编写了一个基本页面,该页面使用了一个布局文件,一个使用Memcached缓存的数据库查询,页面上的其他内容现在几乎是静态的。 在网上阅读了一些关于Yaf(http://pecl.php.net/Yaf)比Zend更快的内容(所有的测试都是你好世界的应用程序)后,我决定将页面移植到Yaf。所以现在我有两个版本的页面一个在Zend完成,另一个在Yaf中完成。除了使用Zend或Yaf特定类之外,内容和逻辑完全相同。 我首先从本地系统运行ab大约100个并发连接和1000个请求总数 -

ab -c 100 -n 1000 yaf.localab -c 100 -1000 zend.local 是的,结果非常有利于Yaf - Yaf在大约30ms内服务于同一页面,而Zend大约需要140ms(慢5倍)。 由于结果来自本地机器,我决定从同一网络中的另一台机器运行相同的测试。我没有任何其他Linux机器,所以我在Win机器上运行ab测试。令人惊讶的是,从另一台机器运行测试导致Yaf和Zend一样慢,有时甚至更慢。 Zend app从140ms移动到300ms左右,而Yaf从40ms移动到300ms。鉴于唯一的额外内容是内容下载,我不知道是什么可以为Yaf添加这么多额外的时间(理想情况下应该在200ms左右)。有时,Yaf中的一些请求有时甚至超过3secs我的nginx配置文件对于Yaf和Zend都是完全相同的(除了更改根文件夹)并且php-fpm慢速日志中也没有条目 - 所以我猜问题出在我的nginx配置或php-fpm。关于我可能做错的任何线索?

编辑#1 :如果下面有帮助,则来自另一个系统的yaf和zend的-c 10 -n 300的ab结果 -

Server Software:        nginx    
Server Hostname:        yaf.myserver.com    
Server Port:            80    
Document Path:          /  
Document Length:        9464 bytes  

Concurrency Level:      10  
Time taken for tests:   25.662 seconds  
Complete requests:      300  
Failed requests:        0  
Write errors:           0  
Total transferred:      2891700 bytes  
HTML transferred:       2839200 bytes  
Requests per second:    11.69 [#/sec] (mean)  
Time per request:       855.402 [ms] (mean)  
Time per request:       85.540 [ms] (mean, across all concurrent requests)  
Transfer rate:          110.04 [Kbytes/sec] received  

Connection Times (ms)  
          min  mean[+/-sd] median   max  
Connect:        0   84  29.4     78     172  
Processing:   172  759  98.5    764     983  
Waiting:       78  453 147.2    452     842  
Total:        250  843 101.7    842    1061  

=======================  
Zend homepage  
========================  
Benchmarking zend.myserver.com (be patient)  


Server Software:        nginx  
Server Hostname:        zend.myserver.com  
Server Port:            80  

Document Path:          /  
Document Length:        9507 bytes  

Concurrency Level:      10  
Time taken for tests:   23.852 seconds  
Complete requests:      300  
Failed requests:        0  
Write errors:           0  
Total transferred:      2904600 bytes  
HTML transferred:       2852100 bytes  
Requests per second:    12.58 [#/sec] (mean)  
Time per request:       795.081 [ms] (mean)  
Time per request:       79.508 [ms] (mean, across all concurrent requests)  
Transfer rate:          118.92 [Kbytes/sec] received  

Connection Times (ms)  
          min  mean[+/-sd] median   max  
Connect:        0   78  30.9     78     218  
Processing:   172  707  90.8    702    1045  
Waiting:      125  432 143.2    437     749  
Total:        250  785  94.1    780    1108  

* 编辑2 - 本地ab结果*     基准测试yaf.myserver.com(耐心等待)

Server Software:        nginx  
Server Hostname:        yaf.myserver.com  
Server Port:            80  

Document Path:          /  
Document Length:        9464 bytes  

Concurrency Level:      100  
Time taken for tests:   1.495 seconds  
Complete requests:      1000  
Failed requests:        0  
Write errors:           0  
Total transferred:      9639000 bytes  
HTML transferred:       9464000 bytes  
**Requests per second**:    669.08 [#/sec] (mean)  
Time per request:       149.459 [ms] (mean)  
Time per request:       1.495 [ms] (mean, across all concurrent requests)  
Transfer rate:          6298.11 [Kbytes/sec] received  

Connection Times (ms)  
          min  mean[+/-sd] median   max  
Connect:        0    0   0.7      0       3  
Processing:     8  142  24.7    148     182  
Waiting:        8  141  24.5    146     182  
Total:         11  143  24.1    148     182  
**Zend results**  
Benchmarking zend.myserver.com (be patient)  


Server Software:        nginx  
Server Hostname:        zend.myserver.com  
Server Port:            80  

Document Path:          /  
Document Length:        9507 bytes  

Concurrency Level:      100  
Time taken for tests:   7.729 seconds  
Complete requests:      1000  
Failed requests:        0  
Write errors:           0  
Total transferred:      9682000 bytes  
HTML transferred:       9507000 bytes  
**Requests per second**:    129.39 [#/sec] (mean)  
Time per request:       772.886 [ms] (mean)  
Time per request:       7.729 [ms] (mean, across all concurrent requests)  
Transfer rate:          1223.35 [Kbytes/sec] received  

Connection Times (ms)  
          min  mean[+/-sd] median   max  
Connect:        0    0   1.1      0       6  
Processing:    35  738 130.5    769     845  
Waiting:       33  731 129.4    761     841  
Total:         40  738 129.5    769     845  

0 个答案:

没有答案