5

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?

gingerbread
  • 61
  • 1
  • 1
  • 5
  • Is your website written in php? Looks like your hoster has capacity problems. Create a test php file with the following content: ``. 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
  • 1
    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

1 Answers1

5

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
Danack
  • 1,186
  • 1
  • 14
  • 27
Selivanov Pavel
  • 2,126
  • 3
  • 23
  • 47
  • 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