May

24

Don’t Get Fireballed

by Matt Brown

Nothing like kicking up dust about CMS platforms on a Monday, right? Well. I’m just a little fatigued by John Gruber (i.e. Daring Fireball) pointing out that the vast majority of WordPress-powered sites can’t handle the traffic he sends their way.

But thing is, he’s right, mostly. The default configuration of WordPress simply isn’t built to handle more than one new visitor per second.

The good news is: few things in life are as easy as protecting a WP site against heavy traffic. If you can install WP to begin with, you can likely install the single plugin needed to make it run as fast as your web host will allow.

How WordPress Works

A default WP install configures your site to run dynamically. Every page request hits the database a number of times (about 15 queries) to present any post or page. This usually takes just a fraction of a second. And since most blogs aren’t very popular (sorry everyone, it’s true!), this tends not to be much of an issue.

But if you do get internet famous, you’ll run into issues with site stability. For example, if a popular blogger links to you, your site will probably tank (and everyone will be looking at this).

If you’re smart enough to write something that people want to read (the hard part), it’d be wise to make sure everyone can see it (easy!). Here’s how.

Enter WP Super Cache

Ask anyone who knows anything about databases, and they’ll tell you this rule of thumb: only talk to the database when you really need to. If you’re letting WP constantly pester your database server on every user request, things aren’t going to be fun. You’re making everybody work hard when there’s a much, much better way.

WP Super Cache is the simple solution. It seamlessly converts your WP website into a set of static HTML pages. If there’s one thing that’s easy for a webserver to do, it’s to serve up regular ‘ole HTML pages and assets. Apache can crank those things out for eternity.

If you’re running a current version of WP, here’s how to install it:

  • Go to “Plugins → Add New”
  • Search for “WP Super Cache”
  • Click “Install”
  • Ensure your file permissions are correct (the only difficult part)
  • Activate the plugin

If you’re competent at installing web software it should take you less than three minutes to get this running correctly. Here’s a more complete installation guide.

It’s important to point out that, while not perfect, WP Super Cache is an elegant solution. After you configure it, you can use WP just as you normally would. It handles all the dirty work of keeping your site static to handle load, and yet dynamic when needed (when you add a post, change your templates, a user posts a comment, etc.). 99% of the time it “just works.”

Install this plugin and you likely won’t ever have to worry about WP crumbling under heavy traffic again. And maybe we can keep Gruber from having to link to Google cached versions of our websites.

Here’s a recent example of a WP site that, using WP Super Cache, survived heavy DF traffic, unscathed.

Going further

Of course, there’s a lot more you can do to make your website load faster and run more efficiently. Here are just a few other things that help:

Use a good web host
No amount of great software is going to get you around having a shitty host. While shared hosting has some downsides, I’ve been completely happy with the excellent up-time and support of WebFaction. You’d be smart to sign up today (affiliate link).

Of course, if you really know what you’re doing and manage a popular site, you’re probably 1) not reading this and/or 2) running a dedicated server for your site. Good for you!

Install WP Minify
When I build-out my HTML and CSS templates, I tend to include far too many files. This makes things a bit slow to load, as the HTTP protocol can only juggle downloading so many files at once. Well, this sexy little plugin will take all your CSS and JS, smash them all into just two files, and compress them down to almost nothing. Surprisingly, it makes a noticeable difference.

Host big assets elsewhere
If you’re putting up a big video, make sure to put it on Vimeo or YouTube. Same goes for MP3s. If you’re clogging up your server with big downloads, people won’t be able to read your posts.

Don’t go crazy
Just remember: Don’t go overboard with optimization. Your site probably isn’t popular enough to need all of this (mine isn’t). Good optimization always begins with the highest-return, simplest configuration fixes — in WP’s case, a caching framework like WP Super Cache is simply the best way to protect against high traffic and keep your server running happy.

Separator

Sorry, we're not taking on new projects.

We packed up shop in early 2011 to work at Facebook. Tiffani now works at Pinterest and Matt is working on secret projects. To keep up with us, check out the Brown Blog or follow @brownthings and @ticjones!