Case Study: WordPress Popular Posts Performance
Our performance audit team is constantly on the lookout for slow client code that is running on Pressjitsu servers. Code that can be optimized yields significant performance gains, making our clients happy with faster WordPress sites, handling more requests.
A recent problem we’ve been battling was post views and page views counters. A handful of our client WordPress sites were using different kinds of rating and pageviews plugins, hit-counters. Most of these did not work well with caching plugins, but more importantly they created a higher load on the server, than is acceptable for sites with a decent amount of traffic.
Our first step was to create and release a simple online service API called Pageviews. As we deployed and configured our Pageviews plugin to our client sites, we saw considerable performance gains.
As the plugin was being used in the wild, with many themes integrating with our Pageviews API, feature requests started flowing in. A few of these requests were for a widget, that would output the most popular posts based on the gathered data.
Not only would this make a handful of rating and popular posts plugins irrelevant for some of our clients, but it would also offer noticeable performance improvement over more traditional solutions. So we decided to build it.
One client site in particular (a popular poker training site) was struggling with the WP-PostRatings plugin, which works great for small sites, but quickly becomes a bottleneck on larger sites, especially ones where users tend to vote. A lot.
A large overhead was due to the AJAX calls and the sorting/ranking code, as well as the large amount of transients that end up in the wp_options table for long periods of time. With high user voting activity the options table quickly grew to an unmanageable size.
Unfortunately the site owner could not remove the ratings plugin, mainly because the most important blocks on their homepage, the “popular posts” sections, were powered by those votes and ratings.
The new Pageviews widget we’ve built sounded like a great replacement. They’ve already been using our Pageviews plugin for quite a while, so we had enough historical data. It made sense to replace those homepage sections by something more performant, and remove the WP-PostRatings plugin once and for all.
As you can see, the response time improved significantly right after deactivating WP-PostRatings. The options table (shown in a graph earlier) got eventually cleaned out by our built-in transients cleaner, and flattened at around 400 rows. The overall load on the server has also dropped and stabilized, so we’re now able to handle uncached requests much faster.
The site users lost the ability to vote on content, but it was something the site owner was willing to sacrifice for significantly better overall performance. They were very happy with the results.
“This is nice and all, but where can I get this for my WordPress site?”
If you are using the Pageviews plugin already, you can grab the widget on our GitHub here: Pageviews Widget free of charge. If you’d like to customize the widget output, like add post thumbnails, view counts, etc., look towards the
You’re welcome to contact us if you encounter any issues or have any feedback for us. If you’re not hosting with Pressjitsu yet, then find out why you should. Meanwhile, we’ll be studying other performance issues out there, so stay tuned :)