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

Getting a Grip on CDN Performance - Why and How

Embed Size (px)

DESCRIPTION

View CDN performance data, learn how you can collect data on CDN performance and get tips on improving CDN performance.

Citation preview

Page 1: Getting a Grip on CDN Performance - Why and How

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

How many sites use a CDN?

Page 3: Getting a Grip on CDN Performance - Why and How

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

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

Total load time (median) in US

Page 6: Getting a Grip on CDN Performance - Why and How

Total load time (mean) in US

Page 7: Getting a Grip on CDN Performance - Why and How

DNS time (median) in US

~25% of total

Page 8: Getting a Grip on CDN Performance - Why and How

DNS time (mean) in US

Page 9: Getting a Grip on CDN Performance - Why and How

Connect time (median) in US

Page 10: Getting a Grip on CDN Performance - Why and How

First byte time (median) in US

Page 11: Getting a Grip on CDN Performance - Why and How

First byte time (mean) in US

Page 12: Getting a Grip on CDN Performance - Why and How

Transfer time (median) in US

Page 13: Getting a Grip on CDN Performance - Why and How

initcwnd of CDNs

http://www.cdnplanet.com/blog/initcwnd-settings-major-cdn-providers/

Page 14: Getting a Grip on CDN Performance - Why and How

Weekdays vs Weekends (mean)

Different demographic:

More people connect through

proxies on weekdays

Page 15: Getting a Grip on CDN Performance - Why and How

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

Australia: different playing field

Page 17: Getting a Grip on CDN Performance - Why and How

CloudFront opened a POP in Sydney

Local POP always wins

Page 18: Getting a Grip on CDN Performance - Why and How

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

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

Green: not so good in California

Page 21: Getting a Grip on CDN Performance - Why and How

Much better in New York

Page 22: Getting a Grip on CDN Performance - Why and How

15 kb versus 100 kb file

Measure performance of content you have

Page 23: Getting a Grip on CDN Performance - Why and How

Monitoring CDN Performance

http://www.flickr.com/photos/59632563@N04/6261230701/

Page 24: Getting a Grip on CDN Performance - Why and How

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

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

Hits from far-away POPs

Page 27: Getting a Grip on CDN Performance - Why and How

'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

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

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

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

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

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

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

Why use a 16 KB file?

Page 35: Getting a Grip on CDN Performance - Why and How

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

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

Tips for improving CDN performance

http://www.flickr.com/photos/ol1/5539623423/

Page 38: Getting a Grip on CDN Performance - Why and How

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

initrwnd of CDNs

Page 40: Getting a Grip on CDN Performance - Why and How

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

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

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

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

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

http://www.flickr.com/photos/27282406@N03/4134166721/

Page 46: Getting a Grip on CDN Performance - Why and How

www.turbobytes.com