Recently I noticed that my WordPress blog seemed to be running dog slow. The admin control panel was taking 30 seconds to load and it was taking even longer to bring up the list of posts. Static content was loading just fine but it seemed like anything that had to query the database was extremely slow.
My blog is hosted on a shared server from HostGator which has actually worked very well so far, although at times I’ve noticed that the server seems to become bogged down. My guess was someone else on my server was putting the MySQL database under a heavy load and slowing things down for everyone on the server. One of the big drawbacks of shared vs dedicated hosting is that you don’t know how much other people are using the server, but with dedicated servers comes a higher price.
Database Performance Statistics
HostGator allows you to access phpMyAdmin through the cPanel interface which provides some statistics on MySQL database usage. I noticed that the value for slow_queries was fairly high but since I don’t have root access to the server I couldn’t tell what the value of long_query_time was set to. So this value alone isn’t a guarantee that there is a problem with the database.
There were a few other values that showed up in red within phpMyAdmin such as Innodb_row_lock_time_avg , and Qcache_lowmem_prunes. This seemed to suggest that the database may be a bit busy.
I decided to contact HostGator’s tech support department and ask them to take a look at the server. Below is the transcript of my chat with them.
System: There are currently 0 people in front of you and 171 chat technicians assisting customers.
Susan Tu: Welcome to Hostgator live chat, my name is Susie. Please bear with me a moment while I look into that for you.
Susan Tu: Well, it looks like the server might’ve had some high loads a little bit ago, but they have already lowered again. And they weren’t too high even. The site itself loaded very quickly for me though. Is it still loading slowly for you?
Sam: the site loads quickly but any functions that query the database from within wordpress take a very long time
Sam: lately this seems to have been happening quite frequently
Susan Tu: Do you have any caching plugins like W3 Total Cache?
Sam: no, none that I’m aware of. I’m not familiar with total cache
Sam: should I be using that?
Susan Tu: I would suggest using it if the queries have been slowing down. You may also want to see about getting the databases optimized.
Sam: ok, I will look into those items
Sam: I appreciate you looking in to the issue, if it persists I will get back in touch with you
Sam: closed this chat intentionally.
I was expecting the support agent to indicate that the server was in fact overloaded so I was both surprised and skeptical by the response. The agent did make a couple of interesting suggestions though. One was to use the W3 Total Cache plugin for WordPress, and the second suggestion was to optimize my database.
PhpMyAdmin has a function that will optimize your databases so I ran the optimize function on all of my tables. My WordPress database so the process did not take very long.
Optimizing the tables didn’t seem to cure my performance issue so I decided to look into the W3 total cache plugin. I did some research on this plugin and it seems to be very popular. W3 can cache almost any aspect of a WordPress blog using memory and disk caching. The plugin is pretty simple to set up and has lots of options that advanced users can tweak if they want to.
I ran a speed test on my blog using YSlow before and after installing W3 Total Cache and did see some improvement in the test score. I was still seeing really bad performance in my WordPress admin control panel though.
Disabling WordPress Plugins
Since I was still seeing issues I spoke with Hostgator support to see if there was anything they could do since nothing seemed to be working. During this chat they asked me if I had disabled all of my WordPress plugins. At first I was frustrated by this response but then I decided to comply with their request and disable all of the plugins I was using.
Well after disabling all of my plugins the slow performance issues disappeared! I was really surprised by this since I had been using the same plugins for quite some time and the slow performance issue had only recently appeared.
I begin re-enabling my plugins one at a time to find out which one of them was causing the problems. It turned out that the Web Ninja Google Analytics plugin was causing the problem. I’m not sure what caused this plugin to begin having issues but I decided it wasn’t worth worrying about since I could simply find another plugin to use.
Yoast offers a Google Analytics plugin that works qutie well, I’m actually a big fan of all of the plugins that Joost has created.
Part of why I enjoy troubleshooting problems is that I usually learn new things during the process of solving an issue. The key things I learned from this problem were..
1. If your having problems with WordPress disable all of your plugins and see if the problem still exists.
2. Database statisics are really only valuable if you have a benchmark to compare it to, such as past performance stats.
3. It’s probably a good idea to use a caching plugin such as W3 Total Cache. In most cases it probably helps and I don’t think it can do any harm, especially on a shared server.
4. Database performance on a shared server is not guaranteed. If you want to ensure no one else is abusing your database get a dedicated server.
5. Listen to the suggestions from HostGator’s tech support 🙂