Harnessing the Power of CDNs Gurpreet Luthra, Lead Consultant
Agenda • What is a CDN? • Brief on Akamai • Advantages of a CDN • Exploiting Caching • Statistics & Numbers • Architectural Considerations • Further References
About Me - Gurpreet Luthra • 13+ years, Developer & Lead Consultant • Working on Scala • Spent last few months harnessing Akamai • Twitter: _zenx_
What is a CDN? http://my-retail-store.com (GET)
What is a CDN? Hash Table Cache for all your HTTP Get Requests http://my-retail-store.com (GET)
What is a CDN? Ha Spread them all over the World! Ha Ha Ha Ha Ha Ha ORIGIN
CDN Distribution Scheme "NCDN - CDN" by Kanoha - Own work. Licensed under CC BY-SA 3.0 via Wikimedia Commons http://commons.wikimedia.org/wiki/File:NCDN_-_CDN.png#/media/File:NCDN_-_CDN.png
Examples of CDNs https://hostingreview360.com/top-5-cdn-providers/
Examples of CDNs
• 15-30% of all Web Traffic • $1.96 Billion Annual Revenue • 5000+ employees • 170,000 Servers in 102 countries • 2 trillion daily Internet interactions http://www.akamai.com/html/about/facts_figures.html
http://www.akamai.com/html/technology/real-time-web-monitor.html
How do I know if a website is using Akamai? 12
13
https://control.akamai.com/EdgeAuth/login.jsp
https://control.akamai.com/EdgeAuth/login.jsp
Recap — Why CDN? • Caching: Reduced Page Construction Time • Closer: Reduced Latency • Traffic Offloaded: Reduced Loads • Backup: Served even if site is down • Protection: Prevent DoS Attacks • Others: Redirects/Auto-compression/Best-route detection
Types of Caches on the Internet • Web browser • Proxy • CDNs • Reverse Proxies • Web Server’s / Specialized Caches
What would we love? • Cache Forever • Deploy immediately
So… Exploit Caching…
HTTP Response Cache Headers • Expires • Cache-Control • Last-Modified • ETag
cache-control • max-age= (seconds) • s-maxage= • public • private • no-cache • must-revalidate • proxy-revalidate https://www.mnot.net/cache_docs/#CACHE-CONTROL
https://redbot.org/
Fingerprinting • Javascripts • CSS • Assets http://server.com/css/global-908e25f4bf641868d8683022a5b62f54.css
Fingerprinting HTML Pages Not fingerprinted 5 - 30 mins JS/CSS/Assets Fingerprinted 1 year Images 30 days - 1 year
Cookie-less Domain • Why submit cookies for every GET request for assets? http://my-assets-host.com/css/ global-908e25f4bf641868d8683022a5b62f54.css
Caching & SSL? http://www.akamai.com/dl/feature_sheets/fs_edgesuite_securecontentdelivery.pdf
Impact on one Website • 85% - 90% Traffic offloaded to Akamai • MONTH • Assets: 100 GB (3KB Cookie) • Assets: 16 Million requests • Traffic: 47 TB (Akamai) • Traffic: 4 TB (Origin) • Peak: 742 Hits/sec (Akamai) • Peak: 47 Hits/sec (Origin)
Architectural Considerations • Page Fragments • User Centric Data - Client Side - AJAX • Mobile/Non-Mobile Views in one payload
FROM: http://ahcdn.com/en/
Further References • The minimum about Web caching you should know: https:// www.mnot.net/cache_docs • http://www.mobify.com/blog/beginners-guide-to-http-cache- headers/ • http://guides.rubyonrails.org/asset_pipeline.html • http://www.ietf.org/rfc/rfc2616.txt (Section 14.9) • http://ocw.mit.edu/courses/mathematics/18-996-topics-in- theoretical-computer-science-internet-research-problems- spring-2002/lecture-notes/ • http://www.akamai.com/dl/technical_publications/ GloballyDistributedContentDelivery.pdf • Image Credits: http://publicdomainvectors.org/
40
Gurpreet Luthra http://techie-notebook.blogspot.com _zenx_
Harnessing The Power of CDNs

Harnessing The Power of CDNs