Scaling A Read Heavy WordPress Blog

I finally caved in. I migrated to WordPress.

I know I know, it’s not that impressive or news worthy. However it does reflect me getting older and wanting to simplify my life. Keeping the end goals in mind and keeping things (relatively) simple to achieve them.

My last setup was pretty scalable. My site was exported to an AWS S3 bucket, media content stored in CDNs to cut down cost, and form submissions were handled by AWS Lambda functions. I wrote the blogging platform using clojurescript, and didn’t want to continue investing time into expanding it. It cost a few pennies a month to run, but it was a highly custom stack.

So, how can we scale WordPress when we expect a TON of incoming traffic (such as going viral)? And how do we do so in a manner thats’s pretty much hands off and cost effective?

A simple setup could be:

Cloudflare <----> WordPress (example.com )

We can configure Cloudflare to cache all GET requests to our WordPress site (less password protected pages and pages viewed while logged in as an editor/admin). I wrote a custom wordpress plugin to do this.

This can work decently. However, someone could knock your server offline by sending requests which responses aren’t cached (POST requests, tampering query parameters, etc.) If you’re just interested in keeping GET requests always available, you could do something like:

Cloudflare <----> Amazon S3 (example.com) <----- WordPress (uploads static content) 
\
`--------> WordPress api.example.com
handles dynamic content created by POST requests

Amazon S3 would host all your content (such as by converting wordpress site to static pages). Any dynamic requests can be sent to your WordPress server via a separate domain.

If you’re still worried the WordPress server api.example.com is going to be knocked offline, you will have to do some additional scaling on the WordPress server side. This could be scaling up (more ram/cpu), scaling different potions of WordPress (DB Webserver, etc.) across multiple servers as necessary, or using some external queue service to take in and forward requests periodically.

Note people who leave comments may not see them on page refresh, due to caching. Purging caches can work for this. This may be necessary anyways, as many pages have links/widgets which link to newer posts when added,



Leave a Reply

Your email address will not be published. Required fields are marked *