When you create a new bucket in Amazon S3, you can choose from five different locations: US Standard, Northern California, Ireland, Singapore and Tokyo.

Most web applications however have visitors from all around the world. So if you choose US Standard, visitors from the east coast will have a very low latency while visitors from Europe and Asia will have to wait longer for the resources stored on Amazon S3.
A common approach to this problem is using a Content Delivery Network (CDN). A CDN consists of many servers all around the world all holding copies of the resources of your web page. So a visitor from the US would get content from a server in the US, a visitor from Asia would receive the content from an asian server and a European from a server in Europe. This guarantees low latency and better bandwidth for visitors from all locations.
I’m using S3 for 3-6-5-days.com with a US Standard bucket. I wasn’t really happy with the latency, but luckily setting up a CDN for your S3 bucket is as easy as pie.
All you need to do is this (I will assume you’re already signed up for S3 and created a bucket):
- Sign up for Amazon Cloud Front.
- Click on Create Distribution and select the bucket which you want to distribute through Cloud Front CDN)

- Now, specify whether you support http and https or only https. Only you can configure whether your resources should be available for streaming or downloading.

- On the last screen, hit Create Distribution
- You’re done! The distribution is configured now. Amazon will automatically start deploying the resources to the various edge locations, in the US, Asia and Europe.
There are two more things that need to be done outside of the Amazon AWS Management Console:
- You need to create a subdomain and configure the CNAME you specified when creating the distribution. So for above example I would create a subdomain like this: cdn.3-6-5-days.com. The CNAME would point to the domain name you see in the Amazon AWS Management Console. It is something like 123xyz.cloudfront.net
- Once subdomain and CNAME are configured you’re ready to use the CDN in your web application. Simply make sure that instead of loading resources from the bucket URL you use your new CDN URL. For above exmaple that would be cdn.3-6-5-days.com/path/to/resource/test.css
Here is another good article about the topic: How to Setup Amazon S3 with CloudFront as a Content Delivery Network
I'm a Software Developer, currently working at