Setting up Amazon S3 as Content Distribution Network for your blog
I have just setup Amazon Cloud Front to work with this blogs caching plug-in “WP Super Cache“. After spending the last 3 hours trying to figure out how to get this to work, I have finally managed to work it out, and it’s not very hard at all.
Just before I go into how to setup Amazons CDN (content Delivery Network) onto a word press site, I’d like to cover what CDN is and how it can benefit your business blog.
Known as Content Delivery Network or Content Distribution Network, in simple terms is set of servers around the world which store a copy of your website files. Once setup on your website, it works as a chacing system, when a user request to view your website, the CDN will display the user with the files from the closest server which has a copy of your website files. The CDN server is also in constant communication with your original host to ensure that the files are up to date at all times.
By setting up a CDN, you are increasing your websites load time, as the files are being fetched from your local server, and also reduces your bandwidth.
Advantages of CDN
Faster: As your site is being displayed from the nearest cached server, the time for your site to load up will be much faster, along with any downloads done from your website will be at a much faster speed. This will help your site especially if you have large files, or high traffic, and users are noticing a slow speed. By setting up a CDN your distributing your content from various locations and severs. Which will put less strain on your main hosting server.
Up-Time: As the original site has stored in various locations on these CDN servers, if your main server was to ever go down, the impact of it would not be as devastating, as the users are being redirected to your cached server. By setting up a CDN you have more control on the delivery of your content.
Cost: It may seem quite expensive to setup a CDN, in fact it’s not, you only pay for what you use with Amazon S3, and many other CDN providers. Compared to your standard hosting it may work out quite cost effective especially if you keep going over your usage allowance, and are being charged extra for usage.
Setting up Amazon S3 / Cloudfront
1. The way I have set up CDN is quite simple, using the plugin WP Super Cache.
Install and activate the plug-in, First of all I have installed and activated the plug-in. Using the standard install tools within wordpress.
2. Using the Amazon Web Services account, activate “Cloud Front” Which will take a few minutes to activate. Once activated, click on “Create Distribution. Enter the below details:
Original DNS Name: the name of your website e.g wasimismail.com
HTTP Port: 80
HTTPS Port: 443
3. Click on Next, and on the next screen in the comments area enter something meaningful so that you remember what this distribution is for.
4. Once you have complete the setup you would be presented with your CDN domain name, such as below:
5. Once you have your domain name, login to your WordPress admin, and navigate to Wp Super Cache settings. Under the CDN tab, enter your CDN domain name such as: http://d2lrzbulqb9b78.cloudfront.net.
After you have clicked on save, on your website you will notice that your images are being fetched from your cloud serer. To Check, right click an image and view it in new tab, you will notice the URL of the image would be something like: http://d2lrzbulqb9b78.cloudfront.net/wp-content/uploads/2011/08/brand.gif