Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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: http://cl.ly/image/213Z3I1o0p37

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: http://cl.ly/image/1T181a452T2R


Test 2 DNS: hosted by company B Website: hosted by company B Test result: http://cl.ly/image/0Z262k2F2M2c

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 professional 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. –  skara 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
add comment

1 Answer 1

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 8.8.4.4 and nameserver 8.8.8.8 I believe these are Google DNS servers –  gingerbread May 12 '13 at 12:47
add comment

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