Page 1 of 1

Need to troubleshoot slow Wordpress Install

Posted: Wed Jul 17, 2013 8:20 pm
by Crayon Shin Chan
My blog, http://ritchan.dasaku.net, takes a long time to respond to a HTTP request. Inserting <?php echo get_num_queries() ?> and <?php timer_stop(1) ?> into the footer gets me:
<div id="footer">
<!-- 2 queries. 0.987 seconds. -->
<!-- Page generated on Thursday 18th of July 2013 01:12:42 AM UTC -->
</div>


But as a whole, the server takes more like 40 seconds to respond. This doesn't happen in the wp-admin pages. What could be going wrong here? Is there something that can tell me what Wordpress is spending its time on? I disabled all plugins already (and used WP-Optimize).

Re: Need to troubleshoot slow Wordpress Install

Posted: Wed Jul 17, 2013 9:40 pm
by just brew it!
Hmm... main page loads very quickly, so it is definitely not server load. I see the long delay if I click the links to any of the individual posts.

Maybe it is stuck waiting for something else to time out, like a DNS lookup?

Re: Need to troubleshoot slow Wordpress Install

Posted: Thu Jul 18, 2013 12:14 am
by thecoldanddarkone
First time loading was slow, really slow. Second pc, it loaded instantly (this is after the first one loaded it really slow).

Re: Need to troubleshoot slow Wordpress Install

Posted: Thu Jul 18, 2013 8:30 am
by Flatland_Spider
thecoldanddarkone wrote:
First time loading was slow, really slow. Second pc, it loaded instantly (this is after the first one loaded it really slow).


I get the same thing too, and when I open a different browser it still loads quickly. I also tried it on a separate test line we have here on a totally separate computer using the Google DNS servers, and it pulled up quickly too.

I think the reason is on the server. I think the PHP cache is expiring on the server, so whenever you go there the http server has to compile the PHP before it can server the webpage. Every request after that will used the compiled versions that are stored in the server cached.

The speed of the compilation is directly affected by the method used for compilation. mod_php is the fastest method for serving PHP, but it's also kind of insecure since it runs as the webserver user. Fast CGI is slower, but it is more secure since it runs as the owner of the files. Since this is a shared webhost, the webserver might be setup to use Fast CGI for security purposes.

These are just guesses, and you'll have to see how the server is setup.

Re: Need to troubleshoot slow Wordpress Install

Posted: Thu Jul 18, 2013 8:31 am
by notfred
It sounds like a reverse DNS lookup. Make sure that all your logging is by IP address and not by hostname.

Re: Need to troubleshoot slow Wordpress Install

Posted: Thu Jul 18, 2013 4:08 pm
by Flatland_Spider
Nevermind, the recursive DNS server was having problems, so my tests were invalid.

Re: Need to troubleshoot slow Wordpress Install

Posted: Sun Jul 21, 2013 12:53 am
by Crayon Shin Chan
notfred wrote:
It sounds like a reverse DNS lookup. Make sure that all your logging is by IP address and not by hostname.

The timing certainly suggests that, but I don't have any logging plugins activated/installed. At least, not that I know of, unless one is already built into WP.

Flatland_Spider wrote:
thecoldanddarkone wrote:
First time loading was slow, really slow. Second pc, it loaded instantly (this is after the first one loaded it really slow).


I get the same thing too, and when I open a different browser it still loads quickly. I also tried it on a separate test line we have here on a totally separate computer using the Google DNS servers, and it pulled up quickly too.

I think the reason is on the server. I think the PHP cache is expiring on the server, so whenever you go there the http server has to compile the PHP before it can server the webpage. Every request after that will used the compiled versions that are stored in the server cached.

The speed of the compilation is directly affected by the method used for compilation. mod_php is the fastest method for serving PHP, but it's also kind of insecure since it runs as the webserver user. Fast CGI is slower, but it is more secure since it runs as the owner of the files. Since this is a shared webhost, the webserver might be setup to use Fast CGI for security purposes.

These are just guesses, and you'll have to see how the server is setup.

The thing is, not even Drupal takes that long to compile. I am hitting the cache somewhere in the pipeline, but I think something else outside of the PHP might be holding it back, but I don't know how to find out what.

Re: Need to troubleshoot slow Wordpress Install

Posted: Mon Jul 22, 2013 7:54 am
by Flatland_Spider
The caching DNS server that my internal DNS servers forward domain names unknown to them was having problems resolving domain names, so it was causing long load times while the domain name lookup timed out at the caching server. This caused me to think something was wrong with your server, but it was a problem on my end.

With that problem fixed, the load time is now inline with other sites. There is a slight pause before the page loads, but it's not on the order of what I was seeing.

Try changing your DNS server to something else, like Google or OpenDNS, and test the site with a clean browser cache to see if it makes a difference.

Re: Need to troubleshoot slow Wordpress Install

Posted: Mon Jul 22, 2013 8:29 am
by Flatland_Spider
There are several online tools that can measure the speed of your webpage.

GTMetrix
http://gtmetrix.com/reports/ritchan.dasaku.net/D9VFZTZU

WebPageTest
http://www.webpagetest.org/result/130722_TK_JWM/

Pingdom Tools
http://tools.pingdom.com/fpt/#!/8Ieh1/r ... dasaku.net

WebsiteOptimizaiton.com
http://www.websiteoptimization.com/services/analyze/

WebWait
http://webwait.com/

Then there are the browser extensions like Google Speed Trace and YSlow.

If you have access to dig you can run the command "dig +trace ritchan.dasaku.net" to trace the DNS requests or "dig @8.8.8.8 + trace ritchan.dasaku.net" to trace the DNS requests using a specific DNS server.