I am getting very high TTFB (Time To First Byte) about 2.6 to 3 seconds, I have very high number of images on my pages.

I want to get thumbs downloaded from multiple host names like:

  • img1.example.com
  • img2.example.com

Do you thinks it will impact the TTFB?


Adding MORE (sub)domains can only INCREASE this value because the computer/visitor has to do another lookup to resolve the domain to an IP.

You'd be better off trying to find out WHY you have a high TTFB.

From Wikipedia: "Time To First Byte or TTFB is a measurement that is often used as an indication of the responsiveness of a webserver or other network resources. It is the duration from the virtual user making an HTTP request to the first byte of the page being received by the browser. This time is made up of the socket connection time, the time taken to send the HTTP request, and the time taken to get the first byte of the page."

...made up of the socket connection time, the time taken to send the HTTP request, and the time taken to get the first byte of the page

  1. Do a test on http://tools.pingdom.com/ to see which part(s) of this is taking the longest.

  2. Post some details about it, so others can help you. I can't say much about exactly how to fix it because I don't know what the problem is exactly.

  • thank you for this answer this is a pingdom test : tools.pingdom.com/fpt/#!/hpxsctNlZ/http://arabeevideo.com you can see that the images are hosted in a part on another domain that serves only images sometimes there's 72 request for that domain while the first generating page I thought that serving them from multiple hostnames will faster page load Now I am sure that the best is to generate some parts with ajax requests – Mahmoud Bahloul Aug 24 '12 at 12:02
  • @MahmoudBahloul - I notice that there is a good amound of "yellow" on that test, which means that your server is preparing to send data to the visitor. You could look into a different server, or CACHING. (Even a CDN?). That will help for sure. – ionFish Aug 24 '12 at 18:10
  • @ionFish: Adding more (sub)domains/hostnames should not increase the TTFB. The additional DNS lookups are made from the client after the first byte is received. – MrWhite Aug 24 '12 at 18:41
  • @w3d - Then the question itself is faulty. "I am getting very high TTFB (Time To First Byte) about 2.6 to 3 seconds, I have very high number of images on my pages." How would the high number of images on the pages make a difference if they are only recognized after the index is downloaded? It's a paradox! (But I think he means his images have a high TTFB and not the index). – ionFish Aug 24 '12 at 18:47
  • Exactly, the TTFB (of the page request) should have nothing to do with the images. That is simply the OP's speculation I suspect. Unless of course, as you suggest, it's not the TTFB that is being measured, but the page load time or something? TBH I'm seeing a much shorter TTFB than the OP suggests, with a total page load time of about 3 secs (but it's varying considerable) - even with an empty cache. – MrWhite Aug 24 '12 at 19:05

TTFB is totally dependent on server load and available bandwidth.

If your server is heavily loaded (lots of requests per second) then your TTFB will rise exponentially. This effect is multiplied by lower server spec and available bandwidth.

Spreading the load over multiple sub domains may or may not have any effect, this depends on how you actually technically do it:

IF you use multiple sub domains linked to the same server, then expect little or no difference.

However if you spread this load over multiple sub-domains pointing do different servers then i could see potential for a lowering of your TTFB - this is how CDN's work.

HOWEVER it is likely that this high TTFB is caused by another factor such as scripts running on every page load - i would investigate the cause before trying to solve it in this way.

  • thank you for your answer my server is an IntelXeon E3-1230 4x 3.2GHz 8 Go DDR3 ECC the connection is 1gbits/sec no idea about bandwith but I think 100MB/s sometimes the php5-cgi goes to 110% in cpu use – Mahmoud Bahloul Aug 24 '12 at 12:10
  • @MahmoudBahloul - Those specifications are plenty fine for what you need. I think the best action to take is to add/improve caching. – ionFish Aug 24 '12 at 18:12

If you are using Apache, check your KeepAliveTimeout value in apache2.conf. When a client is loading multiple files from the server, the connection is normally reused for each, but it looks that's not happening in your case.

The default of 5 should be enough, but try 8 or 10 as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.