CakePHP site's main page's Time to First Byte is very long
Asked Answered
B

1

2

I used pingdom to check for website's loading times. I found some bottlenecks that comes from other domains and fixed them. But slowest part still exist.
Homepage opens nearly in 12 seconds! One second comes from all internal and external js, css and jpeg files. And 11 seconds comes from main page. Details for my home page from the pingdom result:

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

I put tic-toc to beforeFilter and afterFilter of main page's controller. I run it many times in one hour. Result is main page is loaded between 0.15 and 0.35 seconds.

I pinged my server and get the result as 70 ms.

What can I do more to diagnose this latency?
Thank you

Edit: you can check results from this link
Edit2: It seems like my application is run for 0.35 seconds. (It even doesn't have database query in home page) But I can see result on my browser within 10-11 seconds. Is it because of visitor load? Whether too many visitors are using the site at that moment?
Edit3: I still got this problem. I found out that error_log of server has too much records like the below. I hope this would give some information:

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!
Burchette answered 24/8, 2012 at 21:13 Comment(9)
May you privide us with the link to the site or with some code please?Abbess
How long does it take you to access non-Cake files on your server?Madame
I edited question and added link to result.Burchette
Yes non-Cake files are loaded in 40-300 ms.Burchette
Your page size is 1.5MB according to that website???Madame
@WayneWhitty yes but most of the time (12.06 seconds) is spent to one file which is 6 kilobytes.Burchette
Not for me, it was 2 seconds max for your script (avg 1 second) rest of the time is all your assets.Sturrock
Re-run the test, look at the results: tools.pingdom.com/fpt/#!/CsFM2UvSv/http://twitpalas.com - Maybe I was just late and you fixed it already? :)Sturrock
I re-runed tests. Although sometimes I get 2-3 seconds I got 9100 ms of Time to First Byte: webpagetest.org/result/120825_BH_4SQ/1/detailsBurchette
A
2

You have problems with slow page speed because of litespeed installed on your server, you get timeouts (slow response) because you have wrong configuration. Look at your logs you provided. I don't have experience with litespeed but you can try look at these.

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

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

CakePHP and suphp socket, connection reset by peer

Also i recommend you try temporary disable litespeed to make sure it's the main reason.

Aerograph answered 4/9, 2012 at 11:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.