What happens if you drop some short index.html into the webserver's root for testing purposes? Is wordpress involved in this at all, or does the testsite need as much time?
–
Johannes PilleDec 2 '11 at 14:44

10 Answers
10

Before you add your caching layer you need to determine whats slowing down MySql and PHP.

You need to enable WP_Debug and eliminate any PHP errors. Look for undefined indexes, syntax errors and deprecated functions.

That 20 second to first byte is all PHP, MySql and or WordPress related. It sounds like a bad memory leak from poorly written code or extremely long query times. Do you have any expensive queries, e.g. meta_query?

I would recomend installing the Debug Bar and Debug Bar Extender plugins. Enable profiling and set check points at various parts of your templates like before and after any special queries.

To set a checkpoint use the function: dbgx_checkpoint( $note="" ) Use the $note variable to list where the checkpoint is installed.

The profiler will you record the run times and memory usage to pinpoint any problems.

It will also give you a clear picture of the object cache if your using a WordPress object cache plugin.

Also APC, eAccelerator, xCache will not all work at the same time and blow up your site if you try it (I'm sure you probably meant you tried each of them).

I run multiple sites, some having had 4 or 5 3rd party themes run at different times and I've had similar issues. The problem for me was, most of the time, theme/plugin conflicts.

Example: One site had over 30 plugins running and a 3rd party theme and ran fast. Changed to a new theme and the one site started eating up VPS power (I run most sites on a single VPS) and all the sites started slowing down. Amazing really that a theme/plugin conflict could down the whole system. So all the advice about checking plugins is good advice in my opinion. I only run 13 plugins on the site now (bbpress/buddypress and other essentials).

If you can do it yourself or get the developer to do it, modify the theme to do what your plugins did before and you'll have a much more efficient system.

Use mod_deflate in your htaccess and you can manually make your content cachable. CDN is good if you want to serve static content based on visitors location. Those plugins are not good at all. If you are familiar with code and optimization you don´t use them. P3 Plugin Scanner is what shows you which plugins are too heavy ;)

Plugins are often the culprit

Have you tried disabling all plugins and testing your speed there? Usually the inefficient code that can affect a site this significantly is in a poorly coded plugin. If you are still seeing problems, disable all and see if you get a significant change in performance.

Since you are using good caching tools (make sure you have them set up correctly and they aren't fighting each other), the culprit for your main issue is almost always going to be in a bad query somewhere. The folks who code the core of quality CMS's like WordPress and Drupal typically do a great job - not perfect, no code ever is, but core CMS code is going to be superior to plugin code 9 times out of 10.

Sometimes too many cache schemes/tools can work against you

Try Varnish, but not at the same time you have memcached eAccelerator, or xcache enabled. APC should be fine but be mindful. Varnish is a reverse proxy cache that intercepts a request before it gets to the application if that page has already been loaded, and it has given me some fantastic performance increases.

You may want to go into your W3 Total Cache settings and instead of just enabling all of the options try some different combinations. DB caching is usually quite helpful, and APC opcode cache is almost always good for a 35% performance boost but only for the php side of the LAMP stack.

Get your static files on a CDN (Content Distribution Network).

W3 Total Cache has a setting for CloudFlare and I gave it a shot on a slow site. There is a free tier and it still does the job very well for me. They will ask you to change your DNS servers to theirs, that isn't a big deal. It will simply allow them to host your media files and other types of content on a blazing fast server that has geographically distributed access points, reducing the number of hops. It's not precisely applicable to your database issue, but I will use any cost effective (aka free) improvement I can find, and it make a difference.

To use CloudFlare, simply create a free account or upgrade to a higher service level (adds features, not speed) and then all you need to do is follow the directions and plug your API key into the appropriate box in the W3 Total Cache settings page.

PS I have no stake or interest in cloudflare, I'm sure there's plenty of other services, but the integration with W3 Total Cache makes it pretty darn simple, and I was very impressed with the results.

In addition to utilizing all the debug information already list try disabling your plugins and turning them back on systematically to help find any one plugin that may need to be refactored. This also goes for the themes. Try switching to a clean copy of wp's 2011 theme.

I was in a similar situation. In my case it was the custom-made theme that was not updated for a while. I figured it out by changing the theme to default TwentyTen theme (on a test environment), then made the developer to fix/update the theme code.

Running wordpress with heavy theme or many plugin make site damn slow. I had same issue and remove some plugin and speed increased drastically. If you are using many plugin try to remove some of them which are not important.

Before removing plugin you can try to disable all plugin and check what speed you are getting. Than you can try one by one plugin. Wordpress plugins are fine to use but drawback is adding each plugin affect website speed.

If you are using any analytic plugin like Wassup or Whos online etc those plugin also make your site little slow. W3 Total if found sometime make site heavy.

Also check your theme javascripts if you have multiple and heavy javascripts that also make trouble. Some cool portfolio theme having bunch of js and causing site slower. Also loading video, images and audio file from other server like Vimeo or youtube etc make site slower. Vimeo is always gives nice trouble if you check in firefox while loading embedded vimeo video it will keep loading n loading.. these all small small things make site slower.

Try to start from disabling plugin and turning on one by one. Than check js, multiple css. even you can check some dynamic php code for e.g. if you have use bloginfo(); in many pages which has to convert into html during rendering that also you can change to html code but its up to you. check embedded data from other server etc..