Using Amazon CloudFront with WordPress and WordPress MU

Amazon has recently set up a new service called CloudFront, and this week James enabled it for OM4 websites.

Everyone likes web pages that load fast, and one of the factors that determines how fast pages load is the ‘hops’ that are involved in getting all the parts of the web page from the server to the browser.

If your server is in the US and your visitor is in Europe, the page takes longer to load because there are longer (and more) hops involved.

CloudFront has some magic technology that automatically distributes web files across high speed Amazon storage servers in Europe, the US, Japan and Hong Kong. So web files get served from fast locations close to your region.

We are currently using CloudFront for WordPress (and WordPress MU) files that never change. As we extend our use of CloudFront, we will place images and PDFs out in the cloud as well. Dynamic content will come from the core server, and the larger media files will be served from high speed content servers close to the visitor.

Amazon can serve larger files far more efficiently than our servers, and cope with much larger traffic spikes. We already host media in high demand on S3, but until now it has only had one geographical location, not the large number of ‘edge’ servers available with CloudFront.

Hopefully Amazon will extend CloudFront to video soon so we can host video on it as well, although many of our clients like using YouTube to serve video.

Testing results

The initial tests James ran mostly showed a 5-10% reduction in page load times just by offloading the static WordPress files to CloudFront. The one anomaly was when testing our US server by simulating a visitor from a nearby data centre – in that test using the CDN took 3 ms longer rather than 5-10% less.

An OM4 US website

US site loaded from US:
Before: 92.933 [ms]
After: 95.525 [ms]
Result: Slight increase, but this is simulating a visitor in Dallas accessing a web page from another datacentre in Dallas.

US site loaded from Australia:
Before: 728.042 [ms]
After: 687.844 [ms]
Result: 6% decrease in load time

Australian website (Brisbane server) loaded from a Sydney VPS:
Before: 223.972 [ms]
After: 200.033 [ms]
Result: 10% decrease in page loading times loaded from a US server:
Before: 934.519 [ms]
After: 884.088 [ms]
Result: ~5% decrease in page loading times

We already use Amazon S3 to replicate backups off our production servers. So we really like being able to add this new Amazon service to our platform to make it all go faster.

Amazon really have their act together.