我要出去猜测这些是静态文件,而您没有通过 cgi 传递它们。
根据我在分析和谷歌分析方面的经验,这一切都是为了找到瓶颈,或者优化花费最多时间的区域,而不是花费你所有的精力来加速需要 5% 时间的过程。
我想知道更多关于你的设置。一个文件的响应时间是多少?ping 的回程时间是多少?文件有多大?
例如,如果 ping 需要 150 毫秒,那么您的问题是您的网络,而不是您的 nginx 配置。如果文件以兆字节为单位,则它不是 nginx。
如果响应时间在每秒 1 到 30 个请求之间不同,我会假设比更精细的 nginx 调整更激烈。
您能否进一步说明情况?
-- 更新 -- 我在开箱即用的 nginx 服务器上做了一个基准测试,得到一个典型的 index.php 页面。
从服务器内部进行基准测试时:
roderick@anon-webserver:~$ 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)
从我的家庭桌面进行基准测试时:
roderick@Rod-Dev:~$ 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。我可能会猜到两者。
如果修复如此重要,我会得到一个专用服务器。但这只是据我所知。