我打算出去,猜测这些是静态文件,你不通过cgi传递它们。
从我在分析和Google搜索分析方面的经验来看,它的所有关于寻找瓶颈,或优化占用时间最多的领域,并没有花费所有精力来加快占用您5%时间的流程。
我想知道更多关于您的设置。 一个文件的响应时间是多少? ping的回程时间是多少? 档案有多大?
例如,如果ping需要150ms,你的问题是你的网络,而不是你的nginx conf。 如果文件为兆字节,则不是nginx。
如果响应时间在每秒1到30次请求之间不同,我会认为比精细的nginx调整更强烈。
您能否再阐明这种情况?
- update - 我在开箱即用的nginx服务器上做了一个基准测试,得到一个典型的index.php页面。
当从服务器内部基准:
[email protected]:~$ ab -r -n 1000 -c 100 http://anon.com/index.php
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking anon.com (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests
Server Software: nginx/0.8.54
Server Hostname: anon.com
Server Port: 80
Document Path: /index.php
Document Length: 185 bytes
Concurrency Level: 100
Time taken for tests: 0.923 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Non-2xx responses: 1000
Total transferred: 380000 bytes
HTML transferred: 185000 bytes
Requests per second: 1083.19 [#/sec] (mean)
Time per request: 92.320 [ms] (mean)
Time per request: 0.923 [ms] (mean, across all concurrent requests)
Transfer rate: 401.96 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 2 4 1.6 4 9
Processing: 1 43 147.6 4 833
Waiting: 1 41 144.4 3 833
Total: 4 47 148.4 8 842
Percentage of the requests served within a certain time (ms)
50% 8
66% 8
75% 9
80% 9
90% 13
95% 443
98% 653
99% 654
100% 842 (longest request)
当从我的家用台式机基准:
[email protected]:~$ ab -r -n 1000 -c 100 http://anon.com/index.php
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking anon.com (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests
Server Software: nginx/0.8.54
Server Hostname: anon.com
Server Port: 80
Document Path: /index.php
Document Length: 185 bytes
Concurrency Level: 100
Time taken for tests: 6.391 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Non-2xx responses: 1000
Total transferred: 380000 bytes
HTML transferred: 185000 bytes
Requests per second: 156.48 [#/sec] (mean)
Time per request: 639.063 [ms] (mean)
Time per request: 6.391 [ms] (mean, across all concurrent requests)
Transfer rate: 58.07 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 40 260 606.9 137 3175
Processing: 81 214 221.7 140 3028
Waiting: 81 214 221.6 140 3028
Total: 120 474 688.5 277 6171
Percentage of the requests served within a certain time (ms)
50% 277
66% 308
75% 316
80% 322
90% 753
95% 867
98% 3327
99% 3729
100% 6171 (longest request)
我的操作系统是Linux,我的CPU是3岁(这是$ 500的服务器) 。
我已经完成了配置文件没有任何东西。
这是告诉我什么? nginx不是问题。
您的服务器的网络或AWS正在限制您的CPU。我可能会猜测两者。
如果修复很重要,我会得到一个专用的服务器。但那只是我的知识而已。
nginx将http请求转发到在同一台机器上运行的cherrypy服务器,该机器在3 ms内响应一些非静态内容(〜4k字节)。来自客户端IP的traceroute需要25-30 ms。 – haltTm 2012-02-13 12:58:09
一切似乎都很正常。所以我会假设一个http请求会在50-70毫秒左右。 由于没有程序真的在做任何事情,我不得不说,樱桃,或者你的互联网连接是瓶颈。尝试用一个静态文件来重复这个过程,该文件应该能够每秒扩展到10000个请求(或者我们被告知) – 2012-02-13 13:14:13
因为服务器是由AWS托管的,所以Internet连接不成问题。我只是做了一个带有各种并发参数的Apache基准测试。令人惊讶的是,获取20个字节的静态内容(直接来自nginx)的平均/最大时间仅仅比cherrypy提供的动态内容多一点点。所以,cherrypy也不是瓶颈。 – haltTm 2012-02-13 15:05:14