Upgrade to Pro — share decks privately, control downloads, hide ads and more …

LDNWebPerf March 2016 - Tyler McMullen

LDNWebPerf March 2016 - Tyler McMullen

What we can learn from CDNs about Web Development, Deployment, and Performance

More Decks by London Web Performance Group

Other Decks in Technology

Transcript

  1. What we can learn from CDNs
    about Web Development,
    Deployment, and Performance
    Tyler McMullen, CTO & Mad Scientist
    WebPerf Meetup, London March 1st

    View Slide

  2. Lesson:
    People Use Their CDNs Wrong

    View Slide

  3. CDNs offer a toolset
    • The black box approach isn’t always good
    • Configuration isn’t trivial
    – And a lot still depends on configuration
    • Can’t depend on the CDN to solve all your
    problems
    • Don’t exacerbate your problems!

    View Slide

  4. http://bigqueri.es/t/sites-that-deliver-images-using-gzip-deflate-encoding/220

    View Slide

  5. Gzipping Images
    • Not a very good thing for performance
    – Extra bytes
    – Extra work for the browser
    • But was this the Surrogate’s fault?

    View Slide

  6. More Examples
    • Bad caching headers
    – max-age, s-maxage have a lot of power!
    – stale-if-error and stale-while-revalidate are rad!
    • Bad TCP connection management at origin
    • Not Gzipping (actual, compressible content)
    for origin fetches

    View Slide

  7. With Great Power…

    View Slide

  8. Lesson:
    Dynamic Content Is Really Interesting!

    View Slide

  9. What Is Dynamic Content?
    • Stuff that’s not static!
    • With web traffic, generally the base HTML
    – Big deal because it’s blocking
    – And sometimes the largest object; longer download
    • Some AJAX
    • More…

    View Slide

  10. View Slide

  11. Blocking

    View Slide

  12. Classically, with dynamic content…
    Caching

    View Slide

  13. Caching
    vs.
    Invalidation

    View Slide

  14. View Slide

  15. View Slide

  16. View Slide

  17. We tried…

    View Slide

  18. Dynamic Content Caching Problems
    • Serving stale pages
    – Lack of good invalidation framework
    • Visibility
    • Logging

    View Slide

  19. CDNs and Dynamic Content
    • Generally, handling dynamic content has been
    a matter of transport
    – Middle mile optimizations
    – TCP tweaks
    • Some edge micro caching, but not easy
    • ESI

    View Slide

  20. Actually…
    • Dynamic content is more cacheable than we
    think
    • Static for short periods of time
    • Unpredictable invalidation
    – Standard HTTP caching rules aren’t good enough
    • Event-driven Content

    View Slide

  21. So Many Benefits!
    • Performance
    – Faster time to first byte
    – Faster start render
    – Happy users!
    • Offload
    – Less work for our servers
    – Less bandwidth at origin

    View Slide

  22. What Would Make It Better?
    • Programmatic Invalidation
    – Granular
    – Instantaneous
    • Control at the edge, and not just for web
    pages
    – Real-time log files
    – Imagine terminating beacons at the edge!

    View Slide

  23. Lesson:
    Measurement is Still Hard

    View Slide

  24. Client-side Measurement in CDNs
    • Cache hit ratio
    – How do you test and measure?
    • Long tail content?
    • DNS and edge node selection
    • TTFB out of datacenter
    – Memory hit vs disk hit vs mid-tier hit vs miss
    • RUM and synthetic (Cedexis, Catchpoint, etc)

    View Slide

  25. Let’s Test It!
    • 3 Objects on the same CDN (anonymous)
    – Cedexis object
    – Small image from Alexa 5000 site
    – Long tail object: ~40 times every 3-4 hours
    • Use Catchpoint last mile clients in US
    – Test every 15 minutes
    – ~11,500 total tests across all test nodes
    • Focus measurement on:
    – Connect time (TCP)
    – Wait time (TTFB)

    View Slide

  26. Cedexis Object
    Connect (median) Wait (median)
    Cedexis 14ms 19ms

    View Slide

  27. Cedexis Object Alexa 5000
    Connect (median) Wait (median)
    Cedexis 14ms 19ms
    Alexa 5000 14ms 24ms

    View Slide

  28. Cedexis Object Alexa 5000
    Connect (median) Wait (median)
    Cedexis 14ms 19ms
    Alexa 5000 14ms 24ms
    26%

    View Slide

  29. Cedexis Object Long Tail
    Alexa 5000
    Connect (median) Wait (median)
    Cedexis 14ms 19ms
    Alexa 5000 14ms 24ms
    Long Tail 15ms 29ms

    View Slide

  30. Cedexis Object Long Tail
    Alexa 5000
    Connect (median) Wait (median)
    Cedexis 14ms 19ms
    Alexa 5000 14ms 24ms
    Long Tail 15ms 29ms 20%

    View Slide

  31. Cedexis Object
    Count TCP TTFB Count TCP TTFB Count TCP TTFB
    Mem 11,074 14ms 19ms 481 14ms 19ms 6741 14ms 20ms
    Disk 428 12ms 24ms 9626 15ms 28ms 4692 14ms 31ms
    Miss 1 6ms 38ms 1355 16ms 51ms 28 13ms 45ms

    View Slide

  32. Cedexis Object Alexa 5000
    Count TCP TTFB Count TCP TTFB Count TCP TTFB
    Mem 11,074 14ms 19ms 6741 14ms 20ms 481 14ms 19ms
    Disk 428 12ms 24ms 4692 14ms 31ms 9626 15ms 28ms
    Miss 1 6ms 38ms 28 13ms 45ms 1355 16ms 51ms

    View Slide

  33. Cedexis Object Long Tail
    Alexa 5000
    Count TCP TTFB Count TCP TTFB Count TCP TTFB
    Mem 11,074 14ms 19ms 6741 14ms 20ms 481 14ms 19ms
    Disk 428 12ms 24ms 4692 14ms 31ms 9626 15ms 28ms
    Miss 1 6ms 38ms 28 13ms 45ms 1355 16ms 51ms

    View Slide

  34. Cedexis Object Long Tail
    Alexa 5000
    Count TCP TTFB Count TCP TTFB Count TCP TTFB
    Mem 11,074 14ms 19ms 6741 14ms 20ms 481 14ms 19ms
    Disk 428 12ms 24ms 4692 14ms 31ms 9626 15ms 28ms
    Miss 1 6ms 38ms 28 13ms 45ms 1355 16ms 51ms
    99.99%
    Mem: 96.27%
    Disk: 3.72%

    View Slide

  35. Cedexis Object Long Tail
    Alexa 5000
    Count TCP TTFB Count TCP TTFB Count TCP TTFB
    Mem 11,074 14ms 19ms 6741 14ms 20ms 481 14ms 19ms
    Disk 428 12ms 24ms 4692 14ms 31ms 9626 15ms 28ms
    Miss 1 6ms 38ms 28 13ms 45ms 1355 16ms 51ms
    99.99%
    Mem: 96.27%
    Disk: 3.72%
    99.76%
    Mem: 58.82%
    Disk: 40.94%

    View Slide

  36. Cedexis Object Long Tail
    Alexa 5000
    Count TCP TTFB Count TCP TTFB Count TCP TTFB
    Mem 11,074 14ms 19ms 6741 14ms 20ms 481 14ms 19ms
    Disk 428 12ms 24ms 4692 14ms 31ms 9626 15ms 28ms
    Miss 1 6ms 38ms 28 13ms 45ms 1355 16ms 51ms
    99.99%
    Mem: 96.27%
    Disk: 3.72%
    99.76% 88.17%
    Mem: 58.82%
    Disk: 40.94%
    Mem: 4.19%
    Disk: 83.98%

    View Slide

  37. Measurement!
    • Not only do I care about:
    – Cache hit rate
    – Long tail
    – Measuring the right thing
    • Fetching from disk could suck!
    – SSDs!
    • Caching ≠ Caching

    View Slide

  38. Lesson:
    CDNs Are Not Solved!

    View Slide

  39. We Don’t Cache As Much As We Should!
    • HTML and other dynamic content
    • Worse cache hit rate than we think
    – Especially for long tail content
    • Mobile Apps, APIs, etc

    View Slide

  40. Lots of Room
    • Making changes still sucks
    • Can’t take some things for granted:
    – DNS
    – Routing
    – TCP
    – SCALE!
    • Plus: lots of room to be creative at the edge!

    View Slide

  41. Thank you!

    View Slide