Storing your assets on Amazon S3
Amazon S3 makes it really simple to get your assets, aka your stylesheets, images etc off your webserver. There are numerous advantages for this – not only can it save you money in bandwidth it also has an affect on your website performance.
Most browsers (if they comply with the RFC) will open a maximum of 4 HTTP connections to a single URL, that is to say that it is able to load 4 assets simultaneously from a URL – this behaviour is easy to see if you use the Net panel of Firebug, you see the assets ’stair stepping’ as they load.
Now the easiest way to boost your page load time is to create (assuming you have the necessary access to the server) a new virtual server pointing at your assets folder and have it setup with host headers like assets0.yourdomain.com, assets1.yourdomain.com and then ensure that your assets load from http://assets0.yourdomain.com etc…but this still means that it’s coming from the same server.
Enter Amazon S3. It’s marketed as ’storage for the internet’. It’s cheap storage with cheap access rates which can be public or private – to give you some idea of price I store about 25Gb of photos up there and my last bill was about $3 – granted those photos are not accessed so I’m not paying for GET requests since I’m not requesting the data but I sleep soundly knowing all my photos are safely backed up out of my house (I use JungleDisk on my Mac/PC to perform this backup for me!) Anyhow, I digress.
Amazon S3 can be accessed in a variety of ways – the simplest is to use the S3FOX plugin for Firefox. With S3 you start off creating a ‘bucket’. Whilst you can name a bucket anything, it’s best to keep it globally unique using a FQDN, such as assets0.mydomain.com. Amazon will let you create a none globally unique bucket name but behind the scenes it would have been made unique. There are infact different rules for buckets stored in the EU, these must be DNS compatible
Buckets by default are private along with anything you place in the bucket – to allow the assets to be public you need to edit the ACL for the bucket and allow ‘Everyone’ read access and apply this to the subfolders too. Assuming you’ve done that then your assets would now be accessible via http://s3.amazonaws.com/assets0.mydomain.com/ and also via http://assets0.mydomain.com.s3.amazonaws.com/.
But it doesn’t stop there – assuming you’ve setup a FQDN name for your bucket, eg assets0.mydomain.com then you can create a CNAME record in your own DNS for your domain named assets0.mydomain.com and set the value to assets0.mydomain.com.s3.amazonaws.com and then load the assets directly from http://assets0.mydomain.com.
For a more detailed instruction set on Amazon S3 consult the Amazon documentation.
No related posts.



I always enjoy learning what other people think about Amazon Web Services and how they use them. Check out my very own tool CloudBerry Explorer that helps to manage S3 on Windows . It is a freeware. http://cloudberrylab.com/
S3 Browser is a free Amazon S3 Client for Windows. Can be useful to manage your Amazon S3 buckets and files, especially to upload large amount of files to Amazon S3.