Getting to Second Base With Your CDN

A session at Velocity 2009

Tuesday 23rd June, 2009

2:50pm to 3:30pm (PST)

You’ve got a CDN in place, now what? Static objects are the low-hanging fruit that satisfies immediate needs. You’re probably using a CDN either because the bandwidth is cheaper, or you want your media assets to load faster. So what’s next?

1. Measure your performance. How much bandwidth are you serving from origin, and how much has been offloaded to your CDN? You need to have metrics in place to show the results of ongoing optimizations.

2. Tweak your cache TTLs. If you’ve started with short TTLs because your images, CSS, and JavaScript files switch on occasion, think about making these TTLs very long and implement a strategy for purging items from cache or modifying URLs to force your CDN to pick up new versions when you push code changes.

3. Cache dynamic objects. Static objects are very easy to serve and typically very fast, so your major savings by moving to a CDN is in bandwidth. Dynamic objects are more CPU intensive, so caching these has a bigger impact on the performance of your servers. Think hard about what pages you can or cannot cache (search results, Ajax page fragments, etc.).

4. Cache whole pages. How much content on your pages really changes from user to user? Consider moving user-specific logic to small Ajax calls (i.e. personalization) and cache entire pages. How about ad templates with dynamic code in them? Move this logic to client-side JavaScript.

5. Inspect origin hits. Review how many times your CDN is requesting supposedly cacheable files. Are any slipping through the cracks? Are you double-paying for bandwidth… i.e. every request goes back to your origin, costing you origin bandwidth plus CDN bandwidth? Have you forgotten cache-control headers on some requests? Very large files and infrequently accessed files don’t always stick around on the CDN, so they cause origin hits more often. There may be some big surprises in your server logs.

6. Using proper HTTP headers saves bandwidth. When serving dynamic objects, inspect the if-modified-since request headers and respond with “not modified” whenever possible. This saves origin bandwidth costs and reduces origin response time.

7. Use multiple CDNs. This can be considered a redundancy approach, but can also be a big cost-saver. Stick to a high-performance CDN for your premium and hot content—pages that get requested often or have major advertising or sponsorships around them. Find a cheaper CDN for your archives and non-sponsored content. (I did this at Heavy.com making use of Akamai for premium content, and direct access to Amazon S3 for non-sponsored, even before the announcement of their CloudFront service.) Make sure you can measure each CDN and origin separately, and build controls so you can tweak this easily.

8. Review CDN documentation. Each vendor is different. After you’ve gotten past your initial implementation, take a look back over any additional features you glossed over the first time. There may be some gems in there.

9. Engage your vendor. CDNs are out there fighting for business and need to differentiate themselves from being a commodity industry by providing advanced features and responding to customers. Find your technical contact and have a discussion with them about your application and infrastructure. Tell them what additional features you want, even if they seem absurd.

About the speaker

This person is speaking at this event.
Mike Brittain

Engineering Director, Mobile at Etsy. Creator of One tsp., possibly the best recipe organizer in the universe: http://onetsp.com

Coverage of this session

Sign in to add slides, notes or videos to this session

Tell your friends!

When

Time 2:50pm3:30pm PST

Date Tue 23rd June 2009

Short URL

lanyrd.com/sgkmt

View the schedule

Share

Topics

See something wrong?

Report an issue with this session