Taking WordPress to Scale

I originally wrote this post on the 13 Llama Blog.

 

Having your own website and maintaining it has its own set of wins and losses. If your site is not popular enough, that’s a heartburn.

Then one fine day, you get TechCrunched or Mashabled or Redditted – and boom, comes a spike. Or even better, you start doing well on your own and the traffic grows. Soon, this traffic becomes so big, that your existing hosting plan starts creaking and squawking under this load.

This post is for those of you who have a site which has loads of traffic, so much so that the site performance is under impact due to it. Like quite a few of our clients. *Touchwood*

Too much Traffic, a Bad thing?

There’s never such a thing as too much traffic. However, what happens when your existing server hits the peak capacity at which it can serve the responses reliably?

The site seems slower, sluggish – the horde of traffic which is coming to your site start complaining – hey, this site does not load.

This is the next heartburn – you spent all those efforts in building traffic and now you do not want your visitors to have a bad experience because of speed! So what do we do? Do we say no to the additional traffic?

Never! Here’s what we did for one of our clients.

Case Study

Clients: One of the top TV Channels in India in the Food and Lifestyle segment

Problem: Their site was being reported as sluggish and slow. We checked it, and found that the server was taking more than 70 seconds to respond, and a whole 2 minutes went by before the screen showed any elements on the browser!

Impact: When you are such a popular brand, any fault (however small) is blown out of proportion in Social Media. The brand was facing such taunts on their own Social Media Channels, that this became a gigantic issue.

Solution: What we proposed was web performance optimization of their site. Since the site was based on WordPress, most of the things we did to speed up the site can be referred to as ‘Performance Tuning WordPress for Scale’.

Phase I

The first job was looking at the server configuration and changing it to ensure that the memory utilization of Apache and MySQL is optimum. We did this by tweaking the mpm_prefork settings in Apache and by changing the MySQL connection settings in my.cnf.

After this, we installed a caching mechanism on the WordPress platform. We looked at multiple options, and settled on WP Super Cache. The ease with which this plug-in installs and starts serving cached content is simply awesome.

Apart from caching (which had huge savings), we also installed the PageSpeed module which Google has published, on the web server. That, and image smushing.

The result –

Tuning WordPress for Scale
Tuning WordPress for Scale

The loading time dropped from 70 odd seconds to 7 seconds. The site was loading faster and it could handle more requests. This was in the month of September. Over the next 6 months, this site has grown with us.

They are now doing really well on Social Media. In fact a huge 40% of their traffic is due to Facebook!!

With traffic comes one more overhead, the cost of increasing bandwidth! Now, I do not see enough people complaining about this, but if your site is popular and contains rich media, then soon enough, your hosting provider is going to start charging you extra for bandwidth. Don’t be surprised – even Amazon and Rackspace charge for bandwidth.

With around 18,000 visitors hitting the site every day, the hosting provider of the site was facing big issues. Not only was this one server clogging up the network and using up the 10 MBps pipe he had allocated to it, it was asking for more.

 Phase II

Websites which have a lot of static content (js, css, images, etc) should look at this route. Having a CDN ahead of your hosting not only takes the pressure off your server, but also improves the response times of your pages.

We typically use the WordPress’ CDN via JetPack’s Photon. However, in this case, we went with CloudFlare. CloudFlare does multiple things for you and it’s definitely worth checking out. What they do is cache all the static content of the site, and serve that from their network.

The end result –

Taking WordPress to Scale
Taking WordPress to Scale

Unfortunately, I wasn’t quick enough to take a screenshot when the number was above 250 :-)

Using CloudFlare ensured that more content could be served to more number of people at the same time! All of this was done on a single server (Dual Core, 8 GB RAM).

Conclusion

In a lot of the discussions we have had with clients, it seems they think of WordPress as a simple blogging platform instead of a kick-ass powerful Content Management System. One of the major concerns we keep hearing is – Can it Scale?

Well, does this post answer your question?