Hooking a CDN up to S3

As I wrote in my last post, we’ve been going through the process of adding a content delivery network (PantherExpress) to SlideShare. Since there isn’t a lot of information on the net about how to use a CDN to accelerate content that is hosted on S3, I thought I’d publish it here.
The way you integrate with any CDN is pretty much the same.
1) Create a subdomain (e.g. static.slideshare.net) for your domain.
2) Point that subdomain to your CDN (e.g. 132.pantherexpress.com) using a CNAME entry in your DNS.
3) Configure the CDN to know that the “origin server” they should use is your amazon S3 bucket.
4) When the CDN gets a live request for a piece of content, it serves the content if it has it in it’s cache. Otherwise, it fetches the content from the origin server and then serves it.
This is great if you’re starting out. But what if you’ve already launched? You NEED to be able to try out your CDN integration, and then quickly back it out if it isn’t working. There’s two ways to go here.
1) If you’ve thought ahead, you’ve named your s3 bucket after your subdomain (e.g. static.slideshare.net) then you can point your CNAME entry to to bucket. To switch to your CDN, change the CNAME entry. If there’re a problem, switch back. The switch will take however long your “time to live” is set to in DNS.
2) OTOH, you probably WEREN’T forward thinking enough to name your s3 bucket after your subdomain. In this case (the normal case), you have to make sure your webapp is written so that you can quickly change the location where it expects to find external content. We didn’t do that (we had hard-coded the s3 bucket url into the code), so we had to externalize that into a property file that could be easily edited.
So far we’ve accelerated our thumbnails, our javascript / css / navigation images, and all our content players. Still to come is the actual content (the slides themselves). Measured page load time for page loads on media-heavy pages have dropped from 10 seconds to 4 seconds. I’m hopeful that we can use the CDN to accelerate our slides as well.

One thought on “Hooking a CDN up to S3

  1. Andy Forbes May 16, 2008 / 11:23 am

    Happy with Panther Express so far? Any gotchas you can share with me? I gotta set up a CDN for WorthPoint. We’re only pushing 1 TB of images a month right now, but it is starting to accelerate.
    Andy Forbes

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s