Not long ago I was asked to setup a WordPress blog for a site we have on Amazon's EC2 Cloud hosting, and I was surprised to find it so easy.
We already host WordPress sites on our own server cluster in Australia without issues, but I was anticipating having to fight with it, at least a little, to get it working on a bunch of Amazon EC2 instance servers.
I was expecting troubles, because this instance setup is really really simple. Each is running Varnish on port 80, proxying to Apache (on another port), a single MySQL master and with each instance running its own MySQL server as a read only slave. There's no clustered file systems, no shared file base or shared directories and any write access to the DB needs to go via the master server instead.
I was so impressed that it still only took me 5 minutes to setup a blog that I had to mention my success at least somewhere.
The trick was finding WordPress' hyperdb and the s3 image add-on.
Hyperdb (found at http://svn.wp-plugins.org/hyperdb/trunk/) is just 3 files, and comes so well documented it's almost not worth mentioning. It allows WordPress to connect to different database servers for many different scenarios, in this case, I setup WordPress to do all reads from the slave MySQL server on localhost but all writes go to the master server on the local network. Database issues solved.
The Amazon S3 for WordPress add-on does exactly what it's name suggests, instead of storing stuff locally it uploads it to an existing s3 bucket. Without a clustered, shared or replicated file system anything uploaded by bloggers (images etc) would only exist on one of the instance servers. Only users who were randomly allocated that instance server would see the images. Obviously this is a problem. All I did was install the add-on, modified the wordpress-s3/config.php file, and I was done already. File storage solved.
Next I needed to check Varnish, which was suspiciously caching stuff right away. It never feels right when stuff just works so I had to give it a double check, and discovered that because WordPress is smart enough to not set cookies at all until it needs them, it means that my Varnish config worked first go. Probably a safe bet that even Varnish's default config would work fine right out of the box.
Now our mini cloud of only a few instances is running a blog that is hopefully capable of coping with super high loads, if not, we can just add more instances and it'll scale right along with it!
I hope you have as much success as I did.





