Cache Optimization with Akamai


Published on

Published in: Technology
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • Emphasize that we’re primarily a news site and this has certain implications for the longevity of our content – more later…
  • Talk about why we optimize too. These are reasons for choosing Akamai DSD but we also optimize to hold the line on CapEx and OpEx growth.
  • Somewhere in here we want to talk about h uch of the CDN’s value is only realized when it serves > 50% of your content.
  • At the end of this we segue into the next slide by saying you place the needle on the spectrum by understanding your business context…
  • Content is frequently updated when news breaks Old news is irrelevant news – access patterns bear this out
  • The site – and the origin – must stay up no matter how much traffic hits. After that, the content must be fresh. To the business, stale content is worse than no content at all. Cost is mitigated through non-technical means, I.e. choosing a 95 th percentile billing model for DSD traffic so we don’t get hammered on cost by spikes.
  • We’ve been gradually refining our approach, tools, techniques and architecture over the last ten years and we’ve learned a lot. Executing dynamic code for identical requests is silly (Newsdelivery) Don’t ignore architectural changes that you should make at the origin – CDN can only help so much. If your origin stinks, the edge will too. TTL means the time that Akamai will wait before checking the origin for freshness – doesn’t mean that the object will necessarily be retrieved, if it is already in-cache and fresh.
  • Need to validate these numbers.
  • Point out that 83.6% of the requests are 304 Not-Modified, which bears out our strategy of heavily using If-Modified-Since
  • Cache Optimization with Akamai

    1. 1. Blake Crosby Julian Dunn Media Operations and Technology CBC/Radio-Canada Cache Optimization & Origin Infrastructure Reduction Using Akamai Site Delivery
    2. 2. About CBC <ul><li>Canada’s public broadcaster offering services in both English, French, and eight other aboriginal languages. </li></ul><ul><li>Our services are offered in the following formats: </li></ul><ul><ul><li>Radio (FM, AM, Satellite, and Short wave) </li></ul></ul><ul><ul><li>Television (digital cable and OTA. Both standard and high definitions) </li></ul></ul><ul><ul><li>Online ( and </li></ul></ul>
    3. 3. Agenda <ul><li>Why optimize? </li></ul><ul><li>Requirements </li></ul><ul><li>Lessons learned at CBC </li></ul><ul><li>How to optimize </li></ul><ul><li>Current performance </li></ul>
    4. 4. Why Use Akamai Site Delivery? <ul><li>Reduce origin footprint and costs </li></ul><ul><ul><li>Capital expenses and replacement </li></ul></ul><ul><ul><li>Operating (systems admin, power, maintenance) </li></ul></ul><ul><li>Scalability </li></ul><ul><ul><li>Akamai provides CBC with “unlimited” capacity and scaling </li></ul></ul><ul><li>Speed </li></ul><ul><ul><li>Last mile acceleration by being as close as possible to end users </li></ul></ul>
    5. 5. Conflicting Requirements <ul><li>Business: “Make the content as fresh as possible.” </li></ul><ul><li>IT: “Keep the configuration as simple as possible.” </li></ul><ul><li>Finance: “Keep our costs as low as possible.” </li></ul>
    6. 6. The Optimization Spectrum <ul><li>Two ends of the spectrum </li></ul><ul><li>Tune to the Nth degree </li></ul><ul><ul><li>High origin offload </li></ul></ul><ul><ul><li>Content will not appear very fresh due to long TTLs </li></ul></ul><ul><ul><li>Complicated tuning </li></ul></ul><ul><ul><li>Low risk to origin due to spikes in traffic. </li></ul></ul><ul><li>Don’t tune at all </li></ul><ul><ul><li>Lower origin offload </li></ul></ul><ul><ul><li>Content appears very fresh </li></ul></ul><ul><ul><li>No tuning parameters </li></ul></ul><ul><ul><li>High risk to origin due to spikes in traffic </li></ul></ul>
    7. 7. Before Tuning, Understand Your Business and Content <ul><li>CBC is primarily a news site. </li></ul><ul><ul><li>Spiky traffic patterns </li></ul></ul><ul><ul><li>Content has to be fresh </li></ul></ul><ul><ul><li>Content almost never changes after the first 24-48 hours </li></ul></ul><ul><li>Content is not targeted to individuals </li></ul><ul><ul><li>No sessions </li></ul></ul><ul><ul><li>Personalization is done via Javascript </li></ul></ul><ul><li>Deliberate architectural choices: </li></ul><ul><ul><li>Site is mostly static by design </li></ul></ul><ul><ul><li>Server Side Includes technology used heavily </li></ul></ul><ul><ul><li>Executing application layer code for identical requests is wasteful </li></ul></ul><ul><li>The lessons we teach here are domain specific. </li></ul><ul><li>Understand Your Content! </li></ul>
    8. 8. Ultimate Priorities <ul><li>Origin stability </li></ul><ul><li>Content freshness </li></ul><ul><li>Performance </li></ul><ul><li>Cost </li></ul>
    9. 9. Overall Lessons Learned <ul><li>Don’t ignore the architecture of your origin. </li></ul><ul><li>Keep caching rules simple </li></ul><ul><ul><li>Is the default “good enough”? </li></ul></ul><ul><li>Tune at the origin first rather than at the edge </li></ul><ul><ul><li>Reduces propagation time for TTLs during emergencies. </li></ul></ul><ul><li>Understand and categorize content before tuning. </li></ul><ul><li>Understand what “TTL” actually means </li></ul><ul><ul><li>Leads to us heavily leveraging If-Modified-Since </li></ul></ul>
    10. 10. How We Did It <ul><li>Almost no tuning </li></ul><ul><ul><li>Default blanket site TTL of 20s for all objects except HTML; 120s for text/html </li></ul></ul><ul><ul><li>Most objects have no explicit TTL beyond this </li></ul></ul><ul><li>Heavy leveraging of If-Modified-Since </li></ul><ul><ul><li>After TTL expiry, Akamai will issue GET with an If-Modified-Since header </li></ul></ul><ul><ul><li>Origin returns 304 Not Modified if the object hasn’t been changed </li></ul></ul><ul><ul><li>304s account for >85% of our origin hits </li></ul></ul>
    11. 11. Typical Origin Response Codes
    12. 12. How We Did It <ul><li>Control TTLs at origin. </li></ul><ul><ul><li>Fine grain control of object TTLs </li></ul></ul><ul><ul><li>Instant results, no need to wait for Akamai configuration to deploy. </li></ul></ul><ul><ul><li>Ability to adjust TTLs on the fly during special events or emergency situations. </li></ul></ul>Using Apache and mod_expires: <Location &quot;/includes&quot;> ExpiresByType &quot;text/css&quot; &quot;access plus 1 hour&quot; ExpiresByType &quot;application/x-javascript&quot; &quot;access plus 1 hour&quot; ExpiresByType &quot;image/gif&quot; &quot;access plus 1 hour&quot; </Location>
    13. 13. How We Did It <ul><li>Categorize your content. </li></ul><ul><ul><li>We’ve categorized our content into three buckets: frequently changing, moderately changing, and never changing. </li></ul></ul><ul><ul><li>TTLs applied site wide to objects that fall into these categories. </li></ul></ul><ul><li>Some Examples: </li></ul><ul><ul><li>Frequently Changing: </li></ul></ul><ul><ul><ul><li>XML Data Files (live feeds) </li></ul></ul></ul><ul><ul><li>Moderately Changing </li></ul></ul><ul><ul><ul><li>HTML Files (news stories) </li></ul></ul></ul><ul><ul><ul><li>XML Data Files (weather feeds) </li></ul></ul></ul><ul><ul><ul><li>Images </li></ul></ul></ul><ul><ul><li>Never Changing </li></ul></ul><ul><ul><ul><li>Common site elements (navigation) </li></ul></ul></ul><ul><ul><ul><li>Javascript/CSS </li></ul></ul></ul><ul><ul><ul><li>favicon.ico </li></ul></ul></ul>
    14. 14. How We Did It <ul><li>Enable Last Mile Acceleration. </li></ul><ul><ul><li>Using LMA allows Akamai to deliver content as compressed objects to the end user from the edge. </li></ul></ul><ul><ul><li>We also use mod_deflate to compress our content and deliver it to Akamai. </li></ul></ul>
    15. 15. How We Did It <ul><li>Use All Available Cache Headers! </li></ul><ul><ul><li>Cache-Control </li></ul></ul><ul><ul><ul><li>The TTL is located in the “max-age” parameter </li></ul></ul></ul><ul><ul><ul><li>“ public” should also be specified to ensure that other caches cache the content. </li></ul></ul></ul><ul><ul><li>Expires </li></ul></ul><ul><ul><ul><li>The date the object expires </li></ul></ul></ul><ul><ul><li>Last-Modified </li></ul></ul><ul><ul><ul><li>The last-modified header is sent with all objects with the exception of dynamic content and HTML (explained later). </li></ul></ul></ul><ul><ul><li>E-Tag (be careful!) </li></ul></ul><ul><ul><ul><li>E-Tags are a “hash” of the files’ inode and last modified time. </li></ul></ul></ul>
    16. 16. How We Did It Content-Type: text/css Last-Modified: Mon, 07 Jun 2010 15:59:39 GMT Etag: &quot;8a14b9cd-84a-c29470c0&quot; Cache-Control: public, max-age=1557 Expires: Tue, 06 Jul 2010 21:38:51 GMT Date: Tue, 06 Jul 2010 21:12:54 GMT X-Cache: TCP_IMS_HIT from a72-246-43-6 (AkamaiGHost/5.9.4-6329478) (-) X-Cache-Key: /L/1849/9617/0s/ X-True-Cache-Key: /L/ X-Akamai-Session-Info: name=PARENT_SETTING; value=TD X-Serial: 1849 Connection: keep-alive Vary: Accept-Encoding X-Check-Cacheable: YES
    17. 17. Some Gotchas and Annoyances <ul><li>There are some situations which make controlling caching difficult. Here is how we’ve dealt with them. </li></ul><ul><li>Server Side Includes </li></ul><ul><ul><li>Apache cannot calculate the last modified timestamp for files with server side includes (roughly 99% of all html pages on </li></ul></ul><ul><ul><li>We’ve applied a blanket 2 min TTL on all files with the “text/html” content type </li></ul></ul><ul><li>Geolocation </li></ul><ul><ul><li>Server side customization of content will not work as it will be cached for all users. </li></ul></ul><ul><ul><li>We’ve mitigated this by having all customization occur on the client side. If a cookie does not exist, then the browser makes a POST request (which isn’t cached) to the origin to set a cookie which contains the users location. </li></ul></ul>
    18. 18. Tools To Help You <ul><li>Use the Akamai Portal (Akamai Edge Control) </li></ul><ul><ul><li>The “origin OK volume per URL” report is handy in determining which objects are being fetched from the origin. </li></ul></ul><ul><ul><li>404s are not cached. Check the “top URLs, by number of errors” to help you track down broken links. </li></ul></ul><ul><li>Firefox Plugins </li></ul><ul><ul><li>Firebug allows you to view HTTP request and response headers to troubleshoot caching problems. </li></ul></ul><ul><ul><li>Akamai Headers is a plugin that will allow you to view Akamai specific information such as the cache key and which Ghost server responded to your request. Available from Akamai Edge Control. </li></ul></ul><ul><li>Other Resources </li></ul><ul><ul><li>Web Caching By Dune Wessels (O’Reilly and Associates) </li></ul></ul>
    19. 19. Examples (Quebec Earthquake: June 23, 2010)
    20. 20. Examples (Quebec Earthquake: June 23, 2010)
    21. 21. Examples (Quebec Earthquake: June 23, 2010)
    22. 22. Examples (FIFA World Cup: June 11, 2010)
    23. 23. Examples (FIFA World Cup: June 11, 2010)
    24. 24. The Outcome <ul><li>Almost no tunables used </li></ul><ul><ul><li>Meet the requirements using <25 lines of tunables </li></ul></ul><ul><ul><li>No edge tunables in our Akamai metadata config </li></ul></ul><ul><li>Capital Expenditure avoidance </li></ul><ul><ul><li>Ran with six origin webservers from 2003-2010 </li></ul></ul><ul><ul><li>Today we run nine origin webservers at about 40% CPU utilization </li></ul></ul>
    25. 25. Questions Thank You!