Long time to first byte (no wordpress)

I’m trying to optimize my website. Its custom made, uses phpBB-like code and structure, but the code is newly written and optimised, both on php and mysql side.

The webserver is Lighttpd, via fastcgi running php-fcgi v5.3

I see big lag between the DNS lookup and the first bytes being sent, as seen here


When I go microtime my page, it takes only

0.58464700 1313501950
0.63717800 1313501950

0.05 seconds to complete the page, but it takes

0.815 seconds to recieve first byte.

I’m speaking about the very first line (main php page), but I see significant amount of time wasted for first byte in almost all requests.

I wonder why ? Where shall I look for the difference ?

Thank you for any advice.

I see 238ms for the first byte time of the request itself (with dns and socket connect removed) - http://www.webpagetest.org/result/110816_AG_1B583/1/details/#request1

50ms of that is last-mile latency so you’re looking at ~150ms.

Most of the difference is probably in lightppd and fastcgi spining up the php interpreter. Are you using APC to cache the php bytecode?

thank you

yes, im using lighttpd - php-fastcgi - APC in the chain …

yesterday, I moved the DNS to reliable company (until then the DNS was hosted on the same server as the web, and as it seems, secondary was not working, so the DNS resolve might be long) so I will see if it makes any difference (i guess it shouldnt take as much as 0.5 second to do DNS resolve …)

im currently working on caching the pages to harddrive to reduce the PHP processing time and serve as much content static as possible.