【发布时间】:2012-07-31 18:39:59
【问题描述】:
我在 DreamHost 上运行专用服务器:四核,4GB RAM。
Linux (Debian)、Apache、PHP(使用 XCache 进行操作码缓存)、MySQL。
我查询的 URL 每次有 18 个 MySQL 查询。
我想知道为什么当我执行“ab -n 500 -c 50 http://url>/”时会得到以下结果:
Server Software: Apache
Server Hostname: <url>
Server Port: 80
Document Path: /
Document Length: 162809 bytes
Concurrency Level: 50
Time taken for tests: 12.664 seconds
Complete requests: 500
Failed requests: 377
(Connect: 0, Receive: 0, Length: 377, Exceptions: 0)
Write errors: 0
Non-2xx responses: 377
Total transferred: 20291876 bytes
HTML transferred: 20147278 bytes
Requests per second: 39.48 [#/sec] (mean)
Time per request: 1266.372 [ms] (mean)
Time per request: 25.327 [ms] (mean, across all concurrent requests)
Transfer rate: 1564.81 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.4 0 2
Processing: 194 1190 1617.0 248 6060
Waiting: 194 965 1263.9 248 5190
Total: 194 1190 1617.0 248 6060
Percentage of the requests served within a certain time (ms)
50% 248
66% 359
75% 1555
80% 2787
90% 3979
95% 4709
98% 5427
99% 5967
100% 6060 (longest request)
所有 377 个失败的请求都是 503。这可能是什么原因造成的?在执行此操作时运行top,我的处理器飙升至约 24%,但并没有对其征税过多。
我的 CMS 表示,单次加载页面时,加载基类需要 0.0017 秒,控制器执行时间需要 0.1711 秒,总执行时间为 0.1731 秒,使用 2.887 MB 内存。
ab -n 100 -c 10 总是有 0 个失败的请求,但似乎任何并发连接超过 25 个的东西都有一堆失败的连接。
我预计下周会同时出现大量流量,我怎样才能最好地准备我的服务器?这会保持原样吗?
编辑:来自我的 httpd-mpm.conf 文件,该文件是通过 httpd.conf 包含的
<IfModule mpm_worker_module>
StartServers 4
MaxClients 600
MinSpareThreads 50
MaxSpareThreads 150
ThreadsPerChild 25
MaxRequestsPerChild 0
</IfModule>
【问题讨论】:
-
24% 是一个核心的 96%。您是否可能在与 SQL 服务器建立如此多的连接时遇到问题?我假设 apache 服务器上的每次点击都会在 SQL 服务器上造成 18 次点击,这是正确的吗? SQL server 后端是否折叠在连接下?
-
你能发布你的 apache
mpm worker/fcgid/php-fpm配置部分吗?我怀疑你只是用完了并发可服务的请求,因为 http 503 可能只是意味着那个。 -
也许你设置你的服务器限制以避免洪水/DoS攻击?
-
@Wug :即使运行
ab -n 100 -c 30 http://<*url*>/phpinfo.php(没有查询)也会导致 4 个请求失败。 -
@complex857:很遗憾,我不是服务器管理员,但这是我的任务。我知道的足够多,但我不知道这些设置的确切配置位置。检查了 php.ini 但什么也没看到。
标签: php linux performance apache apachebench