php - CakePHP 站点主页的 Time to First Byte 很长

标签 php performance cakephp pagespeed pingdom

我使用 pingdom 来检查网站的加载时间。我发现了一些来自其他领域的瓶颈并修复了它们。但最慢的部分仍然存在。
主页几乎在 12 秒内打开!一秒来自所有内部和外部的 js、css 和 jpeg 文件。 11 秒来自主页。 pingdom 结果中我主页的详细信息:

DNS 157 ms
Connect 213 ms
Send 0 ms
Wait 10.5 s
Receive 56 ms

我将 tic-toc 放入主页 Controller 的 beforeFilter 和 afterFilter 中。我在一小时内运行了很多次。结果是主页在 0.15 到 0.35 秒之间加载。

我 ping 我的服务器并得到结果为 70 毫秒。

我还能做些什么来诊断这种延迟?
谢谢

编辑:您可以查看 this link 的结果
Edit2:我的应用程序似乎运行了 0.35 秒。 (它的主页甚至没有数据库查询)但我可以在 10-11 秒内在浏览器上看到结果。是因为访客量大吗?此时是否有太多访问者使用该网站?
Edit3:我仍然遇到这个问题。我发现服务器的 error_log 有太多记录,如下所示。我希望这能提供一些信息:

Line 384: 2012-09-02 17:39:47.505 [INFO] [92.45.160.177:51491-0#APVH_example.com] connection to [/tmp/lshttpd/APVH_example.com_Suphp.sock.230] on request #361, confirmed, 0, associated process: 705101, running: 1, error: Connection reset by peer!
Line 385: 2012-09-02 17:41:16.223 [INFO] [78.162.236.209:28170-0#APVH_example.com] connection to [/tmp/lshttpd/APVH_example.com_Suphp.sock.671] on request #78, confirmed, 0, associated process: 705246, running: 0, error: Connection reset by peer!
Line 387: 2012-09-02 17:57:15.455 [INFO] [109.228.230.250:54280-0#APVH_example.com] connection to [/tmp/lshttpd/APVH_example.com_Suphp.sock.412] on request #92, confirmed, 0, associated process: 709770, running: 0, error: Connection reset by peer!
Line 388: 2012-09-02 17:58:24.008 [INFO] [95.65.209.252:64082-0#APVH_example.com] connection to [/tmp/lshttpd/APVH_example.com_Suphp.sock.858] on request #500, confirmed, 0, associated process: -1, running: 0, error: Connection reset by peer!
Line 395: 2012-09-02 18:14:53.744 [INFO] [85.103.215.78:54135-0#APVH_example.com] connection to [/tmp/lshttpd/APVH_example.com_Suphp.sock.241] on request #460, confirmed, 0, associated process: 714360, running: 0, error: Connection reset by peer!
Line 401: 2012-09-02 18:34:22.476 [INFO] [78.173.185.165:14411-0#APVH_example.com] connection to [/tmp/lshttpd/APVH_example.com_Suphp.sock.728] on request #500, confirmed, 0, associated process: 720637, running: 1, error: Connection reset by peer!
Line 402: 2012-09-02 18:35:07.269 [INFO] [78.174.20.184:53766-0#APVH_example.com] connection to [/tmp/lshttpd/APVH_example.com_Suphp.sock] on request #26, confirmed, 0, associated process: 720626, running: 0, error: Connection reset by peer!
Line 404: 2012-09-02 18:49:57.659 [INFO] [85.96.10.138:59346-0#APVH_example.com] connection to [/tmp/lshttpd/APVH_example.com_Suphp.sock.728] on request #500, confirmed, 0, associated process: 724847, running: 0, error: Connection reset by peer!
Line 405: 2012-09-02 18:50:44.566 [INFO] [81.6.120.50:39926-0#APVH_example.com] connection to [/tmp/lshttpd/APVH_example.com_Suphp.sock.173] on request #500, confirmed, 0, associated process: 725035, running: 0, error: Connection reset by peer!
Line 413: 2012-09-02 19:15:28.953 [INFO] [78.181.128.53:1344-0#APVH_example.com] connection to [/tmp/lshttpd/APVH_example.com_Suphp.sock.738] on request #500, confirmed, 0, associated process: 731389, running: 1, error: Connection reset by peer!
Line 414: 2012-09-02 19:15:41.572 [INFO] [78.191.100.24:51095-0#APVH_example.com] connection to [/tmp/lshttpd/APVH_example.com_Suphp.sock] on request #500, confirmed, 0, associated process: 731344, running: 1, error: Connection reset by peer!
Line 417: 2012-09-02 19:33:09.700 [INFO] [78.165.162.13:65231-0#APVH_example.com] connection to [/tmp/lshttpd/APVH_example.com_Suphp.sock.317] on request #58, confirmed, 0, associated process: 736102, running: 0, error: Connection reset by peer!
Line 419: 2012-09-02 19:43:16.749 [INFO] [178.233.166.110:51083-0#APVH_example.com] connection to [/tmp/lshttpd/APVH_example.com_Suphp.sock.895] on request #128, confirmed, 0, associated process: 738842, running: 0, error: Connection reset by peer!

最佳答案

由于服务器上安装了 litespeed,您会遇到页面速度缓慢的问题,并且由于配置错误而导致超时(响应缓慢)。查看您提供的日志。我没有 litespeed 的经验,但你可以尝试看看这些。

http://www.litespeedtech.com/support/forum/showthread.php?t=6125

http://bobcares.com/blog/?p=114

CakePHP and suphp socket, connection reset by peer

此外,我建议您尝试暂时禁用 litespeed,以确保这是主要原因。

关于php - CakePHP 站点主页的 Time to First Byte 很长,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12116746/

相关文章:

php - 无法在我的 Amazon Linux 系统 (AWS EC2) 上安装 SQL 服务器

php - 从 php 运行可执行文件而不生成 shell

sql - 用于获取上次更改值的日期时间的高性能查询

css - CSS平铺背景图像的最佳尺寸

php - CakeEmail - 手动发送 HTML 和纯文本消息

php - 在cakephp中的当前url中添加参数

php - 如何使用 PHP 在 OS X 10.5.8 中启用 Sqlite3?

php mail() 发送多封重复邮件

javascript - JavaScript 性能是否受到深度递归的影响?

php - CakePHP 3.x - fixture 导入不加载数据