1

Topic: Using Amazon Cloud Front to serve images

Decided to start playing around by using Amazon S3 and CloudFront to serve up images from my site. I did this more for the learning experience than to solve any types of problems I was having. I would be curious to hear if anyone else is using this and how you did it!

First attempt:

1) Signed up for Amazon S3 (simple storage system) and moved all my site graphics and banners up to it. Changed links on my banners to point to my S3 bucket. Not impressed with the speed as the latency seemed higher at times than from my VPS server.

2) Decided to sign up for Amazon Cloud Front and try serving the images from their network if edge servers. This proved incredibly easy and I could see an improvement on my site page load speeds. To do this I did the following:

a) Created a new CloudFront Distribution using my S3 bucket.
b) Associated the distribution to a CNAME cache.mysite.com
c) created CNAME record in my DNS of: cache.mysite.com pointing to the URL of the distribution in step a.
d) changed link to images to point to cache.mysite.com

Now all my static images (logos, banners, etc) are being served from Amazon edge servers around the world. Within a couple of hours I saw servers in the US, Europe, Japan, and Singapore serving my images. I could see a decrease in page loading time as well. Again, nothing I had to do but kinda cool.

I then wanted to look into having all my members images served from the cloud as I felt I would see a better return by doing this. Initially I though I was was going to have to code in their API (which I still plan on doing) but in the short term found a quick way to do this that so far seems to work.

a) created a new CloudFront Distribution using my current server as the origin server instead of an S3 bucket.

origin server: www.mysite.com
CNAME: images.mysite.com

b) created CNAME record in my DNS of: images.mysite.com pointing to the URL of the distribution in step a.

c) I then changed the virtual_pic_path in my vld config file to use images.mysite.com instead of www.mysite.com

All member profile images, thumbnails, uploaded pics are now being served by the amazon edge servers around the globe.

NOTE: and this may be important! smile I did some basic testing on my site and so far these changes do not appear to have affected anything in a negative way. I am not and cannot say for sure that the change in step c above was an OK one to make. Still very possible I broke something I have not discovered yet. Page load time is definitely improved though!

Doing some basic calculations using my highest traffic month to date (~ 6GB transfers) it looks like all in all this will cost me at most around 1.00 - 2.00 a month but probably less. I can live with that for the speed increase I am seeing so far.

Next up I want to look into their API and if there would be any benefit to using that.

Last edited by DDNY (2011-09-24 13:08:54)

vldPersonals ver: 2.7
Templates by LuvPoint