Current time: 12-18-2017, 07:40 AM Hello There, Guest! (LoginRegister)

Post Reply 
 
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to improve Time To First Byte?
02-27-2011, 01:12 AM
Post: #1
How to improve Time To First Byte?
Performing various tests I observed that the Time To First Byte for the very first resource shown on the graph has always been the longest for my site. Why is that. What's wrong, what could be improved, and how?

The following test result shows the time as being 207 ms, but often it is even a higher number.

http://www.webpagetest.org/result/110226...1/details/

Marvin
Find all posts by this user
Quote this message in a reply
02-28-2011, 10:59 PM
Post: #2
RE: How to improve Time To First Byte?
The first byte time is usually slow because of back-end processing that is done to generate the pages themselves (usually the actual guts of the application/site).

207ms is quite a respectable first byte time though. 80ms of that is the round trip time (I usually just look at the socket connect time as a reasonably good barometer of the RTT to the server). The other 130ms is the time it takes your server to process the request and includes forking processes, starting up whatever interpreter the site uses (php, etc assuming it's not a static HTML file), etc.

If you're not already doing it, the one place that you have control in the application is to "flush early" and send as much of the document as possible before doing any back-end processing (the document head and beginning of the document if at all possible). Getting much faster from where you are is probably going to be an exercise in tuning the web server and application environment itself (and possibly even switching web server platforms if you can't get LiteSpeed to where you want it to).

-Pat
Visit this user's website Find all posts by this user
Quote this message in a reply
03-01-2011, 07:50 AM (This post was last modified: 03-01-2011 07:52 AM by Marvin.)
Post: #3
RE: How to improve Time To First Byte?
Pat, thanks for the valuable feedback. I will be exploring various ways of improving this. I already temporarily disabled my CDN, and asked my host to see if there is any way to address this by tuning up the server. I will also see if I can remove some unneeded code fro m templates, or move things around a bit.

   

The above screenshot shows what I occasionally see, and don't quite understand. Randomly, the time-to-first-byte can be unusually long even for a static file like a 40 byte small clear.gif (1 pixel by 1 pixel in size).

At the time of the above test, the Server Load Averages were as follows:

0.06 0.04 0.02 | 100 Users Online (3 members and 97 guests)

Marvin
Find all posts by this user
Quote this message in a reply
03-01-2011, 08:00 AM
Post: #4
RE: How to improve Time To First Byte?
There could be a couple of causes - if you haven't already, one good way to track it is to enable response time tracking in your access logs (if you're on Apache anyway). That way you can see how long the server thinks every request took to process.

Even if the web server itself isn't overloaded, it's possible the mysql server is (most hosting providers run the database servers on different machines). Does the 1x1 pixel itself have any code behind it to do logging or is it all taken from the access logs? Or if the files are stored on SAN or NFS it's possible that there was a hiccup there.

The other possibility is packet loss. If one of the request or response packets get lost you could see a longer time (though usually it's only really painful for the actual connect time, not the requests themselves since TCP has a better RTT estimate by then).
Visit this user's website Find all posts by this user
Quote this message in a reply
03-01-2011, 09:38 PM
Post: #5
RE: How to improve Time To First Byte?
Pat, thanks a lot. My host is looking into it.

Marvin
Find all posts by this user
Quote this message in a reply
04-06-2011, 07:52 PM (This post was last modified: 04-06-2011 09:02 PM by Kraiser.)
Post: #6
RE: How to improve Time To First Byte?
I'm having same problem with wordpress page running nginx + php fastcgi 5.3.6.
I'm running on my home dedicated server so it's not hosting-hardware fault for sure.
before I added WP-super-cache
http://www.webpagetest.org/result/110406_E7_B80V/
585 ms + 816 ms = 1401ms.

after I added WP-super-cache
http://www.webpagetest.org/result/110406_YV_B820/

it didn't helped me alot there is still time to first bye 611+ 185 ms = 796ms well it's alot.

edit:well whenever I type into webpagetest my domain with www so the server doesn't redirect without www to www the first byte is smaller:
http://www.webpagetest.org/result/110406...ls/cached/
Find all posts by this user
Quote this message in a reply
04-07-2011, 12:36 AM
Post: #7
RE: How to improve Time To First Byte?
If you can, go enable http keep-alives on your server. It should cut the overall load time in half.

Have you tried W3 Total Cache? At least from feedback I have seen it generally works better than Super Cache (and lets you do more advanced optimizations like combine style sheets and js, etc).

-Pat
Visit this user's website Find all posts by this user
Quote this message in a reply
04-07-2011, 01:49 AM (This post was last modified: 04-07-2011 02:08 AM by Kraiser.)
Post: #8
RE: How to improve Time To First Byte?
(04-07-2011 12:36 AM)pmeenan Wrote:  If you can, go enable http keep-alives on your server. It should cut the overall load time in half.

Have you tried W3 Total Cache? At least from feedback I have seen it generally works better than Super Cache (and lets you do more advanced optimizations like combine style sheets and js, etc).

-Pat

comprasion:
with keep-alive enabled:
http://www.webpagetest.org/result/110406_10_BAMD/
without keep-alive:
http://www.webpagetest.org/result/110406_36_BAM4/
it just reduced load time of first time by 400ms. great :-)
anything else?;p
What about that CDN and combine 90% for what is it used for?


Yes I had but it didn't seemed to work at all on nginx maybe I had bad config at nginx (the config was from internet that about cache) or sth I will try that again.
Find all posts by this user
Quote this message in a reply
04-07-2011, 08:53 AM
Post: #9
RE: How to improve Time To First Byte?
Seems like wp super cache is better:
results:
super cache:
http://www.webpagetest.org/result/110406_KH_BDJ0/
total cache:
http://www.webpagetest.org/result/110406_56_BDHF/
Find all posts by this user
Quote this message in a reply
04-07-2011, 09:19 AM
Post: #10
RE: How to improve Time To First Byte?
Make sure to run more than a single test because both platforms need to cache the page the first time it is loaded. Also take a lok at the install docs for W3TC because there are a lot more tweaks that you can do beyond just the base page (though that is critical) to have it automatically combine css, etc for you.
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)