Slide 1

Slide 1 text

+StevenRobertson @_srobertson Making YouTube Fast +AlexNicksay @webdevjesus +RickViscomi @rick_viscomi

Slide 2

Slide 2 text

+AlexNicksay @webdevjesus Faster Navigation at YouTube with SPF

Slide 3

Slide 3 text

data: http://www.youtube.com/yt/press/ image: http://commons.wikimedia.org/wiki/File:Earth_Western_Hemisphere.jpg ! Over 6 billion hours of video are watched each month on YouTube.

Slide 4

Slide 4 text

image: ! That’s almost one hour for every person on Earth. !

Slide 5

Slide 5 text

! We want to get that video to you as fast as possible. !

Slide 6

Slide 6 text

click play Last Year This Year Time to Playback Desktop

Slide 7

Slide 7 text

click Last Year This Year Time to Playback play Desktop

Slide 8

Slide 8 text

click Last Year This Year Time to Playback play Desktop 40% faster

Slide 9

Slide 9 text

Where did we start? ! !

Slide 10

Slide 10 text

Where did we start? ! Real User Monitoring + Analysis

Slide 11

Slide 11 text

click play Critical Stages of Playback

Slide 12

Slide 12 text

fetch info init player load video click Critical Stages of Playback Desktop Last Year play

Slide 13

Slide 13 text

Critical Stages of Playback init player

Slide 14

Slide 14 text

What if we reused the same player? Critical Stages of Playback init player

Slide 15

Slide 15 text

Critical Stages of Playback fetch info init player load video click play Desktop Last Year

Slide 16

Slide 16 text

Critical Stages of Playback fetch info init player load video click play Desktop This Year

Slide 17

Slide 17 text

Persistent = Less Work ! Less Work = Faster

Slide 18

Slide 18 text

How did we do it? ! !

Slide 19

Slide 19 text

How did we do it? ! A new JS framework for page navigation.

Slide 20

Slide 20 text

Structured Page Fragments

Slide 21

Slide 21 text

SPF ! !

Slide 22

Slide 22 text

SPF is a lightweight framework for navigation and page updates.

Slide 23

Slide 23 text

Initial: Static Loading

Slide 24

Slide 24 text

Subsequent: Dynamic Loading with SPF

Slide 25

Slide 25 text

What do we gain? ! !

Slide 26

Slide 26 text

Static fast first render existing performance Benefits

Slide 27

Slide 27 text

SPF Static Dynamic fast first render persistent interface existing performance same rendering code Benefits

Slide 28

Slide 28 text

What do we gain? ! Better User Experience

Slide 29

Slide 29 text

What do we gain? !

Slide 30

Slide 30 text

What do we gain? !

Slide 31

Slide 31 text

And development? ! !

Slide 32

Slide 32 text

Use the same code for static + dynamic. Productivity

Slide 33

Slide 33 text

Use the same code for static + dynamic. Productivity Use any server-side language + templates. Or, send data and use client-side templates. Flexibility

Slide 34

Slide 34 text

How do we implement? ! !

Slide 35

Slide 35 text

Go! Standard Link Request

Slide 36

Slide 36 text

Go! SPF Link Request

Slide 37

Slide 37 text

Go! Standard Link Go! SPF Link Progressive Enhancement Request class=“spf-link”

Slide 38

Slide 38 text

StaticResponse.html Response

Slide 39

Slide 39 text

{ ! "head": "", ! ! "body": { "content": "", }, ! "foot": "" ! } DynamicResponse.spf.json Response

Slide 40

Slide 40 text

DynamicResponse.spf.json { ! "head": "", ! ! "body": { "content": "", }, ! "foot": "" ! }
StaticResponse.html Response

Slide 41

Slide 41 text

But wait, there’s more… ! !

Slide 42

Slide 42 text

Optional Features Custom Caching Reuse Responses Conditionally

Slide 43

Slide 43 text

Custom Caching Prefetching Get Responses Before Requests Optional Features

Slide 44

Slide 44 text

Custom Caching Multipart Responses Prefetching On-the-Fly Processing Optional Features

Slide 45

Slide 45 text

Just how fast is it? ! !

Slide 46

Slide 46 text

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

Slide 47

Slide 47 text

data: YouTube real user monitoring * data for playbacks without ads Composite HTML5 Flash Time to Playback Desktop Median

Slide 48

Slide 48 text

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

Slide 49

Slide 49 text

data: YouTube real user monitoring No Persistence Users Reported Site Felt Faster Time to Playback Desktop Median * data for playbacks without ads

Slide 50

Slide 50 text

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

Slide 51

Slide 51 text

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

Slide 52

Slide 52 text

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

Slide 53

Slide 53 text

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

Slide 54

Slide 54 text

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

Slide 55

Slide 55 text

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

Slide 56

Slide 56 text

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

Slide 57

Slide 57 text

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

Slide 58

Slide 58 text

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

Slide 59

Slide 59 text

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

Slide 60

Slide 60 text

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

Slide 61

Slide 61 text

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

Slide 62

Slide 62 text

What about “regular” pages? ! !

Slide 63

Slide 63 text

data: YouTube real user monitoring 2013-08-14 2014-05-14 Time to Load Search Results Desktop Median

Slide 64

Slide 64 text

data: YouTube real user monitoring Results Time to Load Search Results Desktop Median

Slide 65

Slide 65 text

data: YouTube real user monitoring Time to Load Search Results Desktop Median

Slide 66

Slide 66 text

data: YouTube real user monitoring Time to Load Search Results Desktop Median Video Pages Only

Slide 67

Slide 67 text

data: YouTube real user monitoring Time to Load Search Results Desktop Median All Major Pages

Slide 68

Slide 68 text

data: YouTube real user monitoring Time to Load Search Results Desktop Median Search Results ~22.5% Improvement

Slide 69

Slide 69 text

data: YouTube real user monitoring Time to Load Search Results Desktop Median 22.5% faster

Slide 70

Slide 70 text

What’s next?

Slide 71

Slide 71 text

What’s next? Get the code github.com/youtube/spfjs

Slide 72

Slide 72 text

+AlexNicksay @webdevjesus Thank you! #webperf #spfjs Get the code github.com/youtube/spfjs

Slide 73

Slide 73 text

Web Performance Testing
 at YouTube +RickViscomi @rick_viscomi

Slide 74

Slide 74 text

SPF

Slide 75

Slide 75 text

No content

Slide 76

Slide 76 text

! Only captures static navigation

Slide 77

Slide 77 text

No content

Slide 78

Slide 78 text

logData 0 navigate http://www.youtube.com/ logData 1 navigate http://www.youtube.com/watch?v=ussCHoQttyQ WPT Script Flow View

Slide 79

Slide 79 text

logData 0 navigate http://www.youtube.com/ logData 1 navigate http://www.youtube.com/watch?v=ussCHoQttyQ WPT Script Flow View

Slide 80

Slide 80 text

logData 0 navigate http://www.youtube.com/ logData 1 navigate http://www.youtube.com/watch?v=ussCHoQttyQ WPT Script Flow View

Slide 81

Slide 81 text

logData 0 navigate http://www.youtube.com/ logData 1 navigate http://www.youtube.com/watch?v=ussCHoQttyQ WPT Script Flow View

Slide 82

Slide 82 text

logData 0 navigate http://www.youtube.com/ logData 1 navigate http://www.youtube.com/watch?v=ussCHoQttyQ WPT Script Flow View

Slide 83

Slide 83 text

The cache is warm,
 but it’s still static navigation

Slide 84

Slide 84 text

logData 0 navigate http://www.youtube.com/ logData 1 navigate http://www.youtube.com/watch?v=ussCHoQttyQ WPT Script Flow View

Slide 85

Slide 85 text

WPT Script SPF Transition

Slide 86

Slide 86 text

logData 0 navigate http://www.youtube.com/ logData 1 WPT Script SPF Transition

Slide 87

Slide 87 text

logData 0 navigate http://www.youtube.com/ logData 1 /* click a link to a video */ WPT Script SPF Transition Go!

Slide 88

Slide 88 text

logData 0 navigate http://www.youtube.com/ logData 1 execAndWait WPT Script SPF Transition Go!

Slide 89

Slide 89 text

logData 0 navigate http://www.youtube.com/ logData 1 execAndWait (function(){ var a = document.querySelector(“a[href^=‘/watch?v']"); a.click(); })() WPT Script SPF Transition Go!

Slide 90

Slide 90 text

No content

Slide 91

Slide 91 text

logData 0 navigate http://www.youtube.com/ logData 1 execAndWait (function(){ var a = document.querySelector(“a[href^=‘/watch?v’]"); a.href = “/watch?v=ussCHoQttyQ"; a.click(); })() WPT Script SPF Transition Go!

Slide 92

Slide 92 text

http://www.webpagetest.org/result/140624_18_5Q5/

Slide 93

Slide 93 text

http://www.webpagetest.org/result/140624_18_5Q5/ MISSION ACCOMPLISHED:
 Instrumenting dynamic navigations

Slide 94

Slide 94 text

logData 0 navigate http://www.youtube.com/ logData 1 execAndWait (function(){ var a = document.querySelector(“a[href^=‘/watch?v’]"); a.href = “/watch?v=ussCHoQttyQ"; a.click(); })() WPT Script SPF Transition

Slide 95

Slide 95 text

logData 0 navigate {starting page} logData 1 execAndWait (function(){ var a = document.querySelector(“a[href^=‘{ending page}’]”); a.href = “/watch?v={video ID}“; a.click(); })() WPT Script SPF Transition

Slide 96

Slide 96 text

SPF No SPF No Ads Timecoded Watch Home Search Ads

Slide 97

Slide 97 text

No SPF SPF No Ads Timecoded Watch Home Search Ads

Slide 98

Slide 98 text

Chrome Firefox DSL Cable Watch Home Search IE Dial-up MISSION ACCOMPLISHED:
 Testing dynamic navigations

Slide 99

Slide 99 text

Document Complete First Paint DOM Loaded On Load

Slide 100

Slide 100 text

Video Content

Slide 101

Slide 101 text

Playback Start

Slide 102

Slide 102 text

performance.mark('aft'); main.js Application-Specific Metrics

Slide 103

Slide 103 text

No content

Slide 104

Slide 104 text

v=2&s=youtube&action=watch,watch7_html5&yt_nav=1&yt_pft=none& docid=ussCHoQttyQ&ei=6Q2pU72mMuiI0QHcm4GgDQ&cpn=l2khPNrU oSFcVuQs&fmt=243&tds=4&cmt=0.067&yt_pt=html5&yt_lt=warm&e=9 10133,927625,930008,934030,949401&yt_ref=&yt_spf=1&yt_ad=0&yt_ pl=0&yt_li=0&srt=98&rt=nc0.1,nc1.56,cfg.56,gv.97,nc2.348,je.412,jl. 413,ol.426,tdl.723,fvb.999,plev.1370,vfp.1375,l2s.1378,pbs.1412,arr. 623,vrr.626,msa.667,vda.1278,vri.671,vdns.887,vreq.924,vrc.1274,ari. 668,adns.887,areq.924,fab.983,arc.1258,aft.1412&it=st.89,req.97,dns_. 27,tcp_.35,req_.72,rcv_.332

Slide 105

Slide 105 text

Playback Start http://www.webpagetest.org/google/view_csi.php?test=140624_18_5Q5

Slide 106

Slide 106 text

Playback Start http://www.webpagetest.org/google/view_csi.php?test=140624_18_5Q5 MISSION ACCOMPLISHED:
 Analyzing dynamic navigations

Slide 107

Slide 107 text

Buy the book bit.ly/usingwebpagetest

Slide 108

Slide 108 text

Thank you! Buy the book bit.ly/usingwebpagetest +RickViscomi @rick_viscomi

Slide 109

Slide 109 text

Delivering Media for Interactive Applications +StevenRobertson @_srobertson

Slide 110

Slide 110 text

Pick one.

Slide 111

Slide 111 text

chrome://tracing chrome://net-internals

Slide 112

Slide 112 text

OH RIGHT TRACING

Slide 113

Slide 113 text

No content

Slide 114

Slide 114 text

TCP is affecting your app’s performance.

Slide 115

Slide 115 text

Parallelize loading of small resources.

Slide 116

Slide 116 text

… how about big ones?

Slide 117

Slide 117 text

TCP slow start.

Slide 118

Slide 118 text

No content

Slide 119

Slide 119 text

Exponential growth

Slide 120

Slide 120 text

First packet loss

Slide 121

Slide 121 text

Linear growth

Slide 122

Slide 122 text

DOUBLE THE WOW

Slide 123

Slide 123 text

No content

Slide 124

Slide 124 text

In the long run, parallelized loading can increase throughput…

Slide 125

Slide 125 text

… at the cost of variability.

Slide 126

Slide 126 text

Wireshark whenever you can.

Slide 127

Slide 127 text

No content

Slide 128

Slide 128 text

Wireshark whenever you can.

Slide 129

Slide 129 text

Which is basically never.

Slide 130

Slide 130 text

You can get pretty far with progress events.

Slide 131

Slide 131 text

Which is basically never.

Slide 132

Slide 132 text

No content

Slide 133

Slide 133 text

No content

Slide 134

Slide 134 text

No content

Slide 135

Slide 135 text

Sometimes, things just suck.

Slide 136

Slide 136 text

No content

Slide 137

Slide 137 text

No content

Slide 138

Slide 138 text

So we turned it off.

Slide 139

Slide 139 text

Rebuffer stats got way worse (of course).

Slide 140

Slide 140 text

Watch-time was neutral.

Slide 141

Slide 141 text

One of the most divisive experiments we’ve run.

Slide 142

Slide 142 text

No content

Slide 143

Slide 143 text

We cheated.

Slide 144

Slide 144 text

Give users a way to show you how you could have done better.

Slide 145

Slide 145 text

No content

Slide 146

Slide 146 text

Thank you! #end144p Check out the website youtube.com +StevenRobertson @_srobertson

Slide 147

Slide 147 text

Thank you! #webperf #spfjs #end144p Buy the book bit.ly/usingwebpagetest +StevenRobertson @_srobertson +AlexNicksay @webdevjesus Get the SPF code github.com/youtube/spfjs Check out the website youtube.com +RickViscomi @rick_viscomi