How one small plug-in can slow down your blog
Well I’ll be darned. I am never too old to learn.
Over the past two weeks, I migrated seven blogs from Tumblr to WordPress, onto my VPS (Virtual Private Server) on Hostgator. Concerned about the performance of the server, I scrupulously monitored the CPU, memory and traffic load, as I redirected the domains and as the traffic started to flow in.
There is quite a bit of traffic on those seven blogs, so I use aggressive caching on WordPress, using WP Super Cache.
WP Super Cache has the option to pre-load a set number of posts into a cache: At pre-set intervals, it reads the posts from the SQL database, and converts them to plain HTML files. This way, any visitor gets the pre-cooked HTML file. This creates quite a bit of files, but offloads the server as it does not have to look up each page on the SQLserver. Important for me, as space and bandwidth is not a problem. CPU power is.
That being said, I was astonished to see the CPU load of the server to grow up to the point where everything slowed down. The “Load Average” on the server showed an average of six to ten process waiting to be served. Monitoring the load, I could still see a lot of SQL access happening.
How was that possible? I cached every single page, so no SQL access was needed. I checked and double checked everything. Could not see what caused it these SQL queries. I had everything cached?!?!
Until I found the culprit. I had a plugin “WordPress Popular Posts”, which checked which posts were being accessed, so I could put a “Most Popular Posts” widget in my side column. Thought that would be a cool idea and installed it on all seven migrated blogs.
A cool idea it is, as I use it here on BlogTips. But that is not a cool idea apparently for a high volume site, with limited resources. My poor server was sweating like hell, as apparently all visits are being logged into the database..
I disabled the plugin, cleared the caches, rebuilt them, and voilà.. Almost on the spot the CPU load went down from six to ten processes in the waiting queue to less than two. As anything less than four queued processes per CPU (I have one CPU) is acceptable, my server is a happy camper, I am a happy camper, and my visitors are served with faster websites.
Lessons learned: blog performance is sometimes a matter of plain logical thinking. And often the solution is not in “blaming it on the server”, but looking at the blog in front of you. The “adder under the stone” might be right in front of you, with the venom in juuuust a small plug-in.
And I don’t mean to blame this “Popular Post” plugin. It does what it is supposed to do. But it does not work for high volume sites.