Getting a Grip on CDN Performance - Why and How
-
Upload
turbobytes -
Category
Technology
-
view
3.408 -
download
3
description
Transcript of Getting a Grip on CDN Performance - Why and How
![Page 1: Getting a Grip on CDN Performance - Why and How](https://reader035.fdocuments.in/reader035/viewer/2022081403/554f497ab4c905b9508b4798/html5/thumbnails/1.jpg)
Getting a Grip on CDN PerformanceWhy & How
http://www.flickr.com/photos/59632563@N04/6261230701/
![Page 2: Getting a Grip on CDN Performance - Why and How](https://reader035.fdocuments.in/reader035/viewer/2022081403/554f497ab4c905b9508b4798/html5/thumbnails/2.jpg)
How many sites use a CDN?
![Page 3: Getting a Grip on CDN Performance - Why and How](https://reader035.fdocuments.in/reader035/viewer/2022081403/554f497ab4c905b9508b4798/html5/thumbnails/3.jpg)
CDN Performance in the Real World
http://www.flickr.com/photos/59632563@N04/6261230701/
![Page 4: Getting a Grip on CDN Performance - Why and How](https://reader035.fdocuments.in/reader035/viewer/2022081403/554f497ab4c905b9508b4798/html5/thumbnails/4.jpg)
How we measure CDN performance
Real User Monitoring (RUM)
Download a 16 KB static file from a CDN to a browser > send timing data to our server
More details later on how we do RUM
![Page 5: Getting a Grip on CDN Performance - Why and How](https://reader035.fdocuments.in/reader035/viewer/2022081403/554f497ab4c905b9508b4798/html5/thumbnails/5.jpg)
Total load time (median) in US
![Page 6: Getting a Grip on CDN Performance - Why and How](https://reader035.fdocuments.in/reader035/viewer/2022081403/554f497ab4c905b9508b4798/html5/thumbnails/6.jpg)
Total load time (mean) in US
![Page 7: Getting a Grip on CDN Performance - Why and How](https://reader035.fdocuments.in/reader035/viewer/2022081403/554f497ab4c905b9508b4798/html5/thumbnails/7.jpg)
DNS time (median) in US
~25% of total
![Page 8: Getting a Grip on CDN Performance - Why and How](https://reader035.fdocuments.in/reader035/viewer/2022081403/554f497ab4c905b9508b4798/html5/thumbnails/8.jpg)
DNS time (mean) in US
![Page 9: Getting a Grip on CDN Performance - Why and How](https://reader035.fdocuments.in/reader035/viewer/2022081403/554f497ab4c905b9508b4798/html5/thumbnails/9.jpg)
Connect time (median) in US
![Page 10: Getting a Grip on CDN Performance - Why and How](https://reader035.fdocuments.in/reader035/viewer/2022081403/554f497ab4c905b9508b4798/html5/thumbnails/10.jpg)
First byte time (median) in US
![Page 11: Getting a Grip on CDN Performance - Why and How](https://reader035.fdocuments.in/reader035/viewer/2022081403/554f497ab4c905b9508b4798/html5/thumbnails/11.jpg)
First byte time (mean) in US
![Page 12: Getting a Grip on CDN Performance - Why and How](https://reader035.fdocuments.in/reader035/viewer/2022081403/554f497ab4c905b9508b4798/html5/thumbnails/12.jpg)
Transfer time (median) in US
![Page 13: Getting a Grip on CDN Performance - Why and How](https://reader035.fdocuments.in/reader035/viewer/2022081403/554f497ab4c905b9508b4798/html5/thumbnails/13.jpg)
initcwnd of CDNs
http://www.cdnplanet.com/blog/initcwnd-settings-major-cdn-providers/
![Page 14: Getting a Grip on CDN Performance - Why and How](https://reader035.fdocuments.in/reader035/viewer/2022081403/554f497ab4c905b9508b4798/html5/thumbnails/14.jpg)
Weekdays vs Weekends (mean)
Different demographic:
More people connect through
proxies on weekdays
![Page 15: Getting a Grip on CDN Performance - Why and How](https://reader035.fdocuments.in/reader035/viewer/2022081403/554f497ab4c905b9508b4798/html5/thumbnails/15.jpg)
What happened on June 19?DNS time First byte time
Improvement for all CDNs
Improvement for only 2 CDNs
Better caching at ISPs
Object is more popular > gets served from memory now, or ...
![Page 16: Getting a Grip on CDN Performance - Why and How](https://reader035.fdocuments.in/reader035/viewer/2022081403/554f497ab4c905b9508b4798/html5/thumbnails/16.jpg)
Australia: different playing field
![Page 17: Getting a Grip on CDN Performance - Why and How](https://reader035.fdocuments.in/reader035/viewer/2022081403/554f497ab4c905b9508b4798/html5/thumbnails/17.jpg)
CloudFront opened a POP in Sydney
Local POP always wins
![Page 18: Getting a Grip on CDN Performance - Why and How](https://reader035.fdocuments.in/reader035/viewer/2022081403/554f497ab4c905b9508b4798/html5/thumbnails/18.jpg)
Global performance
Is your CDN fast in your key countries?
http://c.turbobytes.com/static/uploads/velocity12/world-static.html http://c.turbobytes.com/static/uploads/velocity12/world-anim.html
![Page 19: Getting a Grip on CDN Performance - Why and How](https://reader035.fdocuments.in/reader035/viewer/2022081403/554f497ab4c905b9508b4798/html5/thumbnails/19.jpg)
Performance varies between states
How fast is your CDN in your key states?
http://c.turbobytes.com/static/uploads/velocity12/us-state-static.html http://c.turbobytes.com/static/uploads/velocity12/us-state-anim.html
![Page 20: Getting a Grip on CDN Performance - Why and How](https://reader035.fdocuments.in/reader035/viewer/2022081403/554f497ab4c905b9508b4798/html5/thumbnails/20.jpg)
Green: not so good in California
![Page 21: Getting a Grip on CDN Performance - Why and How](https://reader035.fdocuments.in/reader035/viewer/2022081403/554f497ab4c905b9508b4798/html5/thumbnails/21.jpg)
Much better in New York
![Page 22: Getting a Grip on CDN Performance - Why and How](https://reader035.fdocuments.in/reader035/viewer/2022081403/554f497ab4c905b9508b4798/html5/thumbnails/22.jpg)
15 kb versus 100 kb file
Measure performance of content you have
![Page 23: Getting a Grip on CDN Performance - Why and How](https://reader035.fdocuments.in/reader035/viewer/2022081403/554f497ab4c905b9508b4798/html5/thumbnails/23.jpg)
Monitoring CDN Performance
http://www.flickr.com/photos/59632563@N04/6261230701/
![Page 24: Getting a Grip on CDN Performance - Why and How](https://reader035.fdocuments.in/reader035/viewer/2022081403/554f497ab4c905b9508b4798/html5/thumbnails/24.jpg)
Access log files of origin
No data on how fast the CDN is (duh)
Two reasons to analyze 'em:
1. Cache MISS rate
2. Spot patterns in requests from the CDN
![Page 25: Getting a Grip on CDN Performance - Why and How](https://reader035.fdocuments.in/reader035/viewer/2022081403/554f497ab4c905b9508b4798/html5/thumbnails/25.jpg)
Access log files of CDN
Again, no data on how fast the CDN is
Three reasons to analyze 'em:
1. Cache MISS rate
3. Spot HITs from far-away POPs
2. Spot patterns in requests from the CDN
![Page 26: Getting a Grip on CDN Performance - Why and How](https://reader035.fdocuments.in/reader035/viewer/2022081403/554f497ab4c905b9508b4798/html5/thumbnails/26.jpg)
Hits from far-away POPs
![Page 27: Getting a Grip on CDN Performance - Why and How](https://reader035.fdocuments.in/reader035/viewer/2022081403/554f497ab4c905b9508b4798/html5/thumbnails/27.jpg)
'Backbone' synthetic monitoring
Datacenter-to-datacenter != the real world
Tells you nothing about real user experience
Don't use it
![Page 28: Getting a Grip on CDN Performance - Why and How](https://reader035.fdocuments.in/reader035/viewer/2022081403/554f497ab4c905b9508b4798/html5/thumbnails/28.jpg)
Real browser synthetic monitoring
Catchpoint, Gomez, WebPagetest etc.
Real browser, but
– Still in a datacenter
– Not your real users
Close, but no cigar
![Page 29: Getting a Grip on CDN Performance - Why and How](https://reader035.fdocuments.in/reader035/viewer/2022081403/554f497ab4c905b9508b4798/html5/thumbnails/29.jpg)
With-CDN versus Without-CDN
How much faster do your pages load?
WebPagetest:
SetDNSName cdn.domain.com www.domain.comoverrideHost cdn.domain.com www.domain.comnavigate www.domain.com
![Page 30: Getting a Grip on CDN Performance - Why and How](https://reader035.fdocuments.in/reader035/viewer/2022081403/554f497ab4c905b9508b4798/html5/thumbnails/30.jpg)
Google Analytics User Timingsvar startTime;
function loadJs(url, callback) {
var js = document.createElement('script');
js.async = js.src = url;
var s = document.getElementsByTagName('script')[0];
js.onload = callback;
startTime = new Date().getTime();
s.parentNode.insertBefore(js, s);
}
function myCallback() {
var endTime = new Date().getTime();
_gaq.push(['_trackTiming', 'jQuery', 'Load Library', new Date().getTime() - startTime, 'Google CDN', 50]);
};
loadJs('//hostname/path/to/jquery.min.js', myCallback);
https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingTiming
Useless
![Page 31: Getting a Grip on CDN Performance - Why and How](https://reader035.fdocuments.in/reader035/viewer/2022081403/554f497ab4c905b9508b4798/html5/thumbnails/31.jpg)
Resource Timing API
'Navigation Timing for page resources'
Cross-origin resources must be sent with Timing-Allow-Origin:example.com header for API to expose load time details (DNS, etc.)Easy: send header from origin, so CDN sends it too
http://dvcs.w3.org/hg/webperf/raw-file/tip/specs/ResourceTiming/Overview.html
Future!
![Page 32: Getting a Grip on CDN Performance - Why and How](https://reader035.fdocuments.in/reader035/viewer/2022081403/554f497ab4c905b9508b4798/html5/thumbnails/32.jpg)
How we do RUM
http://www.flickr.com/photos/like_the_grand_canyon/4580931101/
![Page 33: Getting a Grip on CDN Performance - Why and How](https://reader035.fdocuments.in/reader035/viewer/2022081403/554f497ab4c905b9508b4798/html5/thumbnails/33.jpg)
Starting points
Measure small object delivery over HTTP
We want the details, not just total load time
No impact on UX
Few beacons from many users, not many beacons from few users
![Page 34: Getting a Grip on CDN Performance - Why and How](https://reader035.fdocuments.in/reader035/viewer/2022081403/554f497ab4c905b9508b4798/html5/thumbnails/34.jpg)
Why use a 16 KB file?
![Page 35: Getting a Grip on CDN Performance - Why and How](https://reader035.fdocuments.in/reader035/viewer/2022081403/554f497ab4c905b9508b4798/html5/thumbnails/35.jpg)
What we actually doNavigation Timing APIloadTime = responseEnd – domainLookupStart
Load 16 kb HTML file from CDN, in invisible iframe
2 lines JS on main page; exec after window.onloadLoad rum.js async (not in IE6-8)
Update localStorage & beacon to server
postMessage timing data from iframe to parentDon't wait longer than 5 seconds
Check localStorage which CDNs may be used
![Page 36: Getting a Grip on CDN Performance - Why and How](https://reader035.fdocuments.in/reader035/viewer/2022081403/554f497ab4c905b9508b4798/html5/thumbnails/36.jpg)
Not all data is good dataNT API implementation is poor in some browsersIgnore FF<9 & Chrome Frame
Is DNS time >0?
We see odd data in Chrome and IE9 too
Is Connect time > 0?Is TTFB >0?
Server side checks include:
![Page 37: Getting a Grip on CDN Performance - Why and How](https://reader035.fdocuments.in/reader035/viewer/2022081403/554f497ab4c905b9508b4798/html5/thumbnails/37.jpg)
Tips for improving CDN performance
http://www.flickr.com/photos/ol1/5539623423/
![Page 38: Getting a Grip on CDN Performance - Why and How](https://reader035.fdocuments.in/reader035/viewer/2022081403/554f497ab4c905b9508b4798/html5/thumbnails/38.jpg)
1
Set a high initcwnd
íf the CDN has a large receive window
http://www.flickr.com/photos/59632563@N04/6261230701/
![Page 39: Getting a Grip on CDN Performance - Why and How](https://reader035.fdocuments.in/reader035/viewer/2022081403/554f497ab4c905b9508b4798/html5/thumbnails/39.jpg)
initrwnd of CDNs
![Page 40: Getting a Grip on CDN Performance - Why and How](https://reader035.fdocuments.in/reader035/viewer/2022081403/554f497ab4c905b9508b4798/html5/thumbnails/40.jpg)
2
Keep connection to CDN open loooong
only íf the CDN wants to keep it open long
http://www.flickr.com/photos/59632563@N04/6261230701/
![Page 41: Getting a Grip on CDN Performance - Why and How](https://reader035.fdocuments.in/reader035/viewer/2022081403/554f497ab4c905b9508b4798/html5/thumbnails/41.jpg)
3
send Vary:Accept-Encoding
… so your CDN sends GZIPed when it should
http://www.flickr.com/photos/59632563@N04/6261230701/
![Page 42: Getting a Grip on CDN Performance - Why and How](https://reader035.fdocuments.in/reader035/viewer/2022081403/554f497ab4c905b9508b4798/html5/thumbnails/42.jpg)
4
don't send Vary:User-Agent
… to prevent a high cache MISS rate
http://www.flickr.com/photos/begnaud/243996426/
![Page 43: Getting a Grip on CDN Performance - Why and How](https://reader035.fdocuments.in/reader035/viewer/2022081403/554f497ab4c905b9508b4798/html5/thumbnails/43.jpg)
5
add jitter to low TTL cache-control
for better UX and origin protection
http://www.flickr.com/photos/59632563@N04/6261230701/
![Page 44: Getting a Grip on CDN Performance - Why and How](https://reader035.fdocuments.in/reader035/viewer/2022081403/554f497ab4c905b9508b4798/html5/thumbnails/44.jpg)
6
set high TTL for DNS
especially important if traffic is low/med
http://www.flickr.com/photos/59632563@N04/6261230701/
![Page 45: Getting a Grip on CDN Performance - Why and How](https://reader035.fdocuments.in/reader035/viewer/2022081403/554f497ab4c905b9508b4798/html5/thumbnails/45.jpg)
http://www.flickr.com/photos/27282406@N03/4134166721/
![Page 46: Getting a Grip on CDN Performance - Why and How](https://reader035.fdocuments.in/reader035/viewer/2022081403/554f497ab4c905b9508b4798/html5/thumbnails/46.jpg)
www.turbobytes.com