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

Faster Navigation at YouTube with SPF (October ...

Faster Navigation at YouTube with SPF (October 2014)

YouTube videos are playing 40% faster than last year.  We’ve introduced SPF (spfjs), a new HTML5 JS framework that now forms the foundation of YouTube navigation and enables our performance improvements.

In this talk, we'll discuss how we use SPF to implement a broad range of performance-improving features — including dynamic page loading, persistent video players, partial page updates, reduced resource execution, custom caching, dynamic page and resource prefetching, and on-the-fly processing of responses — while maintaining fast server-side content rendering at scale. You’ll see how you can seamlessly integrate these features into your site with progressive enhancement and the help of built-in versioning support.

Alex Nicksay @webdevjesus
David Phillips @TheDaveWhoCodes

Presented at eBay — October 6, 2014

Learn more about SPF:
http://youtube.github.io/spfjs/

Alex Nicksay

October 06, 2014
Tweet

More Decks by Alex Nicksay

Other Decks in Programming

Transcript

  1. Use the same code for static + dynamic. Productivity Use

    any server-side language + templates. Or, send data and use client-side templates. Flexibility
  2. <html> <head> <!-- Styles --> </head> <body> <div id="masthead">…</div> <div

    id="content"> <!-- Content --> </div> <div id="footer">…</div> <!-- Scripts --> </body> </html> StaticResponse.html Response
  3. { ! "head": "<!-- Styles -->", ! ! "body": {

    "content": "<!-- Content -->", }, ! "foot": "<!-- Scripts -->" ! } DynamicResponse.spf.json Response
  4. DynamicResponse.spf.json { ! "head": "<!-- Styles -->", ! ! "body":

    { "content": "<!-- Content -->", }, ! "foot": "<!-- Scripts -->" ! } <html> <head> <!-- Styles --> </head> <body> <div id="masthead">…</div> <div id="content"> <!-- Content --> </div> <div id="footer">…</div> <!-- Scripts --> </body> </html> StaticResponse.html Response
  5. Multipart Responses { ... } Standard Response [ { ...

    }, { ... }, { ... } ] Multipart Response Multiple Objects
  6. Multipart Responses { ... } Standard Response [ { ...

    }, { ... }, { ... } ] Multipart Response Delimiters [\r\n { ... },\r\n { ... },\r\n { ... } ]\r\n Multipart Response with On-the-Fly Processing [\r\n { ... },\r\n { ... },\r\n { ... } ]\r\n
  7. data: YouTube real user monitoring * data for playbacks without

    ads 2013-08-14 2014-05-14 Time to Playback Desktop Median
  8. data: YouTube real user monitoring * data for playbacks without

    ads Composite HTML5 Flash Time to Playback Desktop Median
  9. data: YouTube real user monitoring No Persistence Users Reported Site

    Felt Faster Time to Playback Desktop Median * data for playbacks without ads
  10. data: YouTube real user monitoring Video Pages: Chrome Only ~8.5%

    Improvement Time to Playback Desktop Median * data for playbacks without ads
  11. data: YouTube real user monitoring Video Pages: All Browsers ~9.0%

    Improvement Time to Playback Desktop Median * data for playbacks without ads
  12. data: YouTube real user monitoring On-the-Fly over HTTP ~5.0% Improvement

    Time to Playback Desktop Median * data for playbacks without ads
  13. data: YouTube real user monitoring Default HTML5: No Ads ~8.0%

    Improvement Time to Playback Desktop Median * data for playbacks without ads
  14. data: YouTube real user monitoring All Major Pages ~7.5% Improvement

    Time to Playback Desktop Median * data for playbacks without ads
  15. data: YouTube real user monitoring Default HTML5: Ads ~2.0% Improvement

    Time to Playback Desktop Median * data for playbacks without ads
  16. data: YouTube real user monitoring On-the-Fly over SPDY ~4.5% Improvement

    Time to Playback Desktop Median * data for playbacks without ads
  17. data: YouTube real user monitoring Time to Playback Desktop Median

    * data for playbacks without ads 40% faster
  18. data: YouTube real user monitoring Time to Playback Desktop Median

    * data for playbacks without ads Dynamic Navigation 40% faster
  19. data: YouTube real user monitoring Time to Playback Desktop Median

    * data for playbacks without ads Dynamic Navigation Persistent Player 40% faster
  20. data: YouTube real user monitoring Time to Playback Desktop Median

    * data for playbacks without ads Dynamic Navigation Persistent Player Default HTML5 40% faster
  21. data: YouTube real user monitoring Time to Playback Desktop Median

    * data for playbacks without ads Dynamic Navigation Persistent Player Default HTML5 On-the-Fly 40% faster
  22. data: YouTube real user monitoring Time to Load Search Results

    Desktop Median Search Results ~22.5% Improvement
  23. data: YouTube production monitoring 12:00 AM 11:59 PM Day Before

    Aggregate Incoming Request Rate Desktop Requests/Second
  24. data: YouTube production monitoring 12:00 AM 11:59 PM Enable SPF

    Day Before Aggregate Incoming Request Rate Desktop Requests/Second SPF Enabled ~13% Load Reduction
  25. data: YouTube production monitoring 12:00 AM 11:59 PM Day After

    Enable SPF Day Before Aggregate Incoming Request Rate Desktop Requests/Second
  26. Desktop Requests/Second data: YouTube production monitoring 12:00 AM 11:59 PM

    Persistent Interface Custom Caching Aggregate Incoming Request Rate 13% more efficient
  27. <html> <head> <!-- Metadata --> <!-- Styles --> </head> <body>

    <!-- Content --> <!-- Scripts --> </body> </html>
  28. <html> <head> <!-- Metadata --> <!-- Styles --> </head> <body>

    <!-- Content --> <!-- Scripts --> </body> </html> Processes First
  29. <html> <head> <!-- Metadata --> <!-- Styles --> </head> <body>

    <!-- Content --> <!-- Scripts --> </body> </html> Precedes Rendering
  30. <html> <head> <!-- Metadata --> <!-- Styles --> </head> <body>

    <!-- Content --> <!-- Scripts --> </body> </html> Blocks DOM
  31. { title: "…", head: "<!-- Styles -->", body: { content:

    "<!-- Content -->" }, foot: "<!-- Scripts -->", }
  32. { title: "…", head: "<!-- Styles -->", body: { content:

    "<!-- Content -->" }, foot: "<!-- Scripts -->", } Processes First
  33. { title: "…", head: "<!-- Styles -->", body: { content:

    "<!-- Content -->" }, foot: "<!-- Scripts -->", } Styles in the head process next
  34. { title: "…", head: "<!-- Styles -->", body: { content:

    "<!-- Content -->" }, foot: "<!-- Scripts -->", } Content is injected after
  35. { title: "…", head: "<!-- Styles -->", body: { content:

    "<!-- Content -->" }, foot: "<!-- Scripts -->", } Scripts are loaded at the end
  36. { title: "…", head: "<!-- Styles —> <!-- Scripts -->",

    body: { content: "<!-- Content -->" }, foot: "<!-- Scripts -->", } Resources can be in any section
  37. Thank you! Learn more youtube.github.io/spfjs Alex Nicksay @webdevjesus Get the

    SPF code github.com/youtube/spfjs David Phillips @TheDaveWhoCodes #spfjs #webperf