320 likes | 419 Views
Getting to 2nd Base with your Content Delivery Network. Mike Brittain Engineering Architect. Overview. Measure your performance Tweak your cache TTLs Cache dynamic objects Cache whole pages Inspect origin hits Use proper HTTP headers Use multiple CDNs Review CDN documentation
E N D
Getting to 2nd Base with your ContentDelivery Network • Mike Brittain • Engineering Architect
Overview Measure your performance Tweak your cache TTLs Cache dynamic objects Cache whole pages Inspect origin hits Use proper HTTP headers Use multiple CDNs Review CDN documentation Engage your vendor
Overview 20 Minutes
Overview Cache dynamic objects Inspect origin traffic Cache HTML pages
CDN Storage $$$
Origin Pull CDN lingo for “reverse proxy”
Response Headers Cache-control:max-age=3600 Last-Modified: Mon, 16 Mar… ETag: “82c7-378-8e2a” http://www.askapache.com/htaccess/apache-speed-etags.html
Revalidation Requests GET /images/generated.css HTTP/1.1 Host: origin.example.com If-Modified-Since: Mon, 16 Mar … If-None-Match: ”82c7-378-8e2a” HTTP/1.1 200 OK Content-Length: 35043 ... or ... HTTP/1.1 304 Not Modified $$$ $
Avoid Double Paying 16 MB x 4,600 @ 0.35/GB ≈ $25 (CDN) 16 MB x 4,600 @ 0.50/GB ≈$36(origin) $61
Avoid Double Paying 16 MB x 4,600 @ 0.35/GB ≈ $25 (CDN) 16 MB x 23 @ 0.50/GB ≈$0.18(origin) $25 - ish
Cache HTML Pages Page built just for Mike
Cache HTML Pages Serve generic version to the CDN Use client-side logic for personalization
Cache HTML Pages Replace generic sections with tailored versions Cookies, JavaScript
Cache HTML Pages Track short history of user interactions Fresh data only where needed Ajax, Cookies, JavaScript
Cache HTML Pages Use tracking pixels for page views Real time data with Ajax, or fake it Ajax, Cookies, JavaScript
Cache HTML Pages Search Results, HTML frag., Public APIs, XML, JSON, RSS Do you GET it?
Cache HTML Pages TTLs of 3 mins to 1 hr Psst… under 60 seconds is okay, too.
Cache HTML Pages 92%
Thank You Slides, etc. www.mikebrittain.com Questions mike@mikebrittain.com
HTTP Headers cURL, telnet, Charles, Fiddler, Firebug, etc.
CDNs Fail Plan B • Split traffic between (similar) CDNs • Origin servers • Cloud storage
CDNs Fail Amazon CloudFront: $0.17/GB* Rackspace Cloud Files: $0.22/GB JetS3t, Cyberduck, Transit, S3 Browser, S3Fox Plug-in, s3sync.rb, APIs, etc.
Multiple CDNs Cost vs. Performance • Views • Time