Getting a Grip on CDN Performance Why & How.

Size: px
Start display at page:

Download "Getting a Grip on CDN Performance Why & How. http://www.flickr.com/photos/59632563@n04/6261230701/"

Transcription

1 Getting a Grip on CDN Performance Why & How

2 How many sites use a CDN?

3 CDN Performance in the Real World

4 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

5 Total load time (median) in US

6 Total load time (mean) in US

7 DNS time (median) in US ~25% of total

8 DNS time (mean) in US

9 Connect time (median) in US

10 First byte time (median) in US

11 First byte time (mean) in US

12 Transfer time (median) in US

13 initcwnd of CDNs

14 Weekdays vs Weekends (mean) Different demographic: More people connect through proxies on weekdays

15 What happened on June 19? DNS time Improvement for all CDNs Better caching at ISPs First byte time Improvement for only 2 CDNs Object is more popular > gets served from memory now, or...

16 Australia: different playing field Local POP always wins

17 Global performance Is your CDN fast in your key countries?

18 Performance varies between states How fast is your CDN in your key states?

19 Green: not so good in California

20 Much better in New York

21 15 kb versus 100 kb file Measure performance of content you have

22 Monitoring CDN Performance

23 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

24 Access log files of CDN Again, no data on how fast the CDN is Three reasons to analyze 'em: 1. Cache MISS rate 2. Spot patterns in requests from the CDN 3. Spot HITs from far-away POPs

25 Hits from far-away POPs

26 'Backbone' synthetic monitoring Datacenter-to-datacenter!= the real world Tells you nothing about real user experience Don't use it

27 Real browser synthetic monitoring Catchpoint, Gomez, WebPagetest etc. Real browser, but Still in a datacenter Not your real users Close, but no cigar

28 With-CDN versus Without-CDN How much faster do your pages load? WebPagetest: SetDNSName cdn.domain.com overridehost cdn.domain.com navigate

29 Google Analytics User Timings var 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(); Useless _gaq.push(['_tracktiming', 'jquery', 'Load Library', new Date().getTime() - starttime, 'Google CDN', 50]); loadjs('//hostname/path/to/jquery.min.js', mycallback);

30 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 Future!

31 How we do RUM

32 Starting points Measure small object delivery over HTTP We want the details, not just total load time Few beacons from many users, not many beacons from few users No impact on UX

33 Why use a 16 KB file?

34 What we actually do Navigation Timing API loadtime = responseend domainlookupstart 2 lines JS on main page; exec after window.onload Load rum.js async (not in IE6-8) Check localstorage which CDNs may be used Load 16 kb HTML file from CDN, in invisible iframe postmessage timing data from iframe to parent Don't wait longer than 5 seconds Update localstorage & beacon to server

35 Not all data is good data NT API implementation is poor in some browsers Ignore FF<9 & Chrome Frame We see odd data in Chrome and IE9 too Server side checks include: Is DNS time >0? Is Connect time > 0? Is TTFB >0?

36 Tips for improving CDN performance

37 1 Set a high initcwnd íf the CDN has a large receive window

38 initrwnd of CDNs

39 2 Keep connection to CDN open loooong only íf the CDN wants to keep it open long

40 3 send Vary:Accept-Encoding so your CDN sends GZIPed when it should

41 4 don't send Vary:User-Agent to prevent a high cache MISS rate

42 5 add jitter to low TTL cache-control for better UX and origin protection

43 6 set high TTL for DNS especially important if traffic is low/med

44

45