Ever wish you could deliver web pages and graphics at blazing speeds without having to sell your firstborn?
99% of the content of this blog is now speeding from Amazon’s CloudFront Content Distribution Network. Check the page source code – whatever comes from “cloud.negbox.com” is actually coming from a server at an Amazon location near YOU. Yes, YOU. Not me, not my hosting provider… You.
I never thought I would set up my own little CDN in a few hours – I thought these things were hard as hell to set up. Amazon has made it incredibly simple, and you don’t have to pick up the phone to talk to any IT ‘tard. I basically muddled my way through. The really nice bit is that I estimate that for my 3GB of storage and an ungodly amount of traffic on this blog, the monthly cost I would pay for storage, transfer, etc would not exceed a coffee at Starbucks even when I double my realistic estimate. Yup, this is really cheap.
Now imagine hosting your landing page and images on CloudFront. Wouldn’t that be sweet for the PPV mavens?
Turns out Amazon has been offering for some time this service called CloudFront. If you’ve heard of Akamai (by far the biggest name in this field) and other Content Distribution Networks – you know what this is. They put the stuff in a redundant cloud close to the people that request the files. Theoretically if folks from Botswanahilii start requesting your pages, your pages start getting replicated to servers closer to Botswanahilii – That’s the gist of a CDN and I understand CloudFront follows it to some degree – not going to split hairs on this one.
Signing up for Amazon Web Services is dead-simple. Setting up CloudFront is not for the faint of heart – it involved no coding, and can be done easily – but there is little in the way of user-level help screens – you get tons of help pages, but its all aimed at developers. Just do like me: Close your eyes, plug some values that make sense and cross your fingers… You did it on every other test in school – this is no different.
Amazon has a really nice web interface for all their web services… I’m not going to go into how awesome all their other services are – just check them out, they are awesome.
If you’ve got balls of steel, you can follow my instructions:
1 – Signup to AWS (Amazon Web Services) – Give them your billing info.
2 – Go into the AWS interface, go to the tab labeled S3 and “Create a Bucket” any name is fine – if it gives you errors, try a more unique name. “Bucket” is probably taken.
3 – Go into the CloudFront tab and “Create a Distribution” and give it the name of your blog, or your pet Iguana, don’t really matter.
3a – Select download for the type (I really don’t know what the difference is – this is how I did it). On the “Origin” drop down, select the name of the bucket you created on step 2
3b – On the CNAME field, put a subdomain you will be creating for this file distribution service. I chose “cloud” so in that field I put in “cloud.negbox.com” … The way NegBox is set up (no www) I could have perfectly well chosen ”www” on CloudFront and could serve some static pages from http://www.negbox.com/index.html straight from CloudFront (note it doesn’t do “root” or document finding, so pointing your browser at the root of your CloudFront subdomain returns gibberish).
4 – Go to your hosting provider’s DNS tool or your registrar’s DNS tool – Whoever is doing name resolution for you at the moment – and add a CNAME record. The Cname Record has only two pieces of information – One is going to be the name you want to redirect, in this case “cloud.negbox.com” the other piece of info is WHERE you want to redirect it to – that comes from the AWS interface – when you are looking at the CloudFront dashboard you can see your network’s line that says “Delivery Method, Domain, Comment, Bucket”. That domain name that is something like d87sdhs98.cloudfront.com is the second bit of info you need for the CNAME record.
5 – You’re done. Sorta – Now you need to redirect traffic to the cloud.
To get WordPress working with CloudFront I am using W3 Total Cache from Frederick Townes. I can’t even begin to explain what an AMAZING piece of software the W3 Total Cache plugin is. I am simply amazed it is free – he could charge in the hundreds for this piece of software. One hint, though – Don’t use the current distribution release – get the development build 0.9 from wordpres.org, this new release in the pipeline worked flawlessly with CloudFront.
To really use the plug-in is going to take a bit of time to figure out and learn – but its amazing. It scans your site and uploads to the CDN the files it needs, it minifies and caches your pages an uploads the cached pages, updates your .htaccess, goes through all your posts and fetches any content you’ve linked to, brings it into the media library and then exports it to the CDN… In short, it won’t wipe your butt, but it comes pretty close.
If you need some hand-holding, they actually offer support, installation and professional services… Or you could go dig into the much more exhaustive posts on how to use W3 Total Cache with Self-Hosted CDN from Udegbunam Chukwudi and his follow-up post – His post is about self-hosted CDNs, but still very useful.
What does this all translate to? Well, this site loads about 40-50% faster when profiled with simple Safari tools. Yes, the women are coming faster at you.
It also means I’m going to seriously think about how I use CloudFront to accelerate any landing pages, blogs, flogs, etc.
Go forth and Accelerate!