Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I recently changed the host of one of my websites, and I noted that pages are loading slowly. The elements of the page themselves are quickly loaded (the pages are lightweight, CSS and JS are minified, GZIP is on, JPEG are compressed...), but the time to connect to the site seems very high.

So I ran a benchmark to analyse my website. It turns out that the "time to first byte" is extremely high, and I assume this is what I witnessed (the grey spinner on Google Chrome is spinning too much compared to other websites).

The test is available here:

I also witnessed this phenomenon on other websites on the same servers. It's not my Internet connection because it occurred in different places, with high speed connections.

So my question is: what could cause this high "time to first byte"? Should I look into the Apache config, or PHP..?

Can the fact that the DNS servers and the websites are hosted by two different companies respectively affect this time to first load?

Additional informations:

  • Shared hosting
  • Apache 2.2
  • CentOS 6
  • Intel Core i5-3570 CPU @ 3.40GHz / RAM 16 Gb

Edit: I ran 2 tests on simple PHP files -- just a phpinfo().

Test 1 DNS: hosted by company A Website: hosted by company B Test result:

Test 2 DNS: hosted by company B Website: hosted by company B Test result:

The second test shows that it is faster, and I don't understand why. The tests are the same, the code are the same. But the first one has a high time to first byte... Any idea why?

share|improve this question

closed as off topic by EEAA, mdpc, Ward, Jenny D, Tom O'Connor May 12 '13 at 17:51

Questions on Server Fault are expected to relate to server, networking, or related infrastructure administration within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

Is your website written in php? Looks like your hoster has capacity problems. Create a test php file with the following content: <?php phpinfo(); ?>. If it takes almost as long to load as your main page, most probably your web server's php process pool is overloaded and requests have to wait in queue. – skarap May 12 '13 at 12:05
Yes it is written in PHP. I tried the phpinfo() test, it takes a bit of time to pre-load, like my home page, but a bit less. I also noted that when I disable GZIP (via mod_deflate), it looks a bit faster. I reran some speed tests, but they are queuing... Thanks for your advice, I'll contact the support of the hoster to see if they know something. – gingerbread May 12 '13 at 12:27

Your web-server may be trying to write client's hostname in log file, and one of DNS servers configured in /etc/resolv.conf may be answering slowly.

Unless you definitely need the client's hostname for logging purposes, you should ensure that the hostnamelookup is disabled by setting:

HostnameLookups Off
share|improve this answer
Here is what I have in this file: nameserver and nameserver I believe these are Google DNS servers – gingerbread May 12 '13 at 12:47

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