Inside YouTube's Master Plan to Kill Lag Dead
Inside YouTube's Master Plan to Kill Lag Dead

              
              
              There is a moment between when you click on a video and when it starts playing. That moment is the worst part of your day. The agony of waiting! The torture of anticipation! YouTube understands that, and on a visit to YouTube HQ in San Bruno, CA, we got a look at what’s coming to make that awful moment pass before you know it happened.

 According to John Harding, YouTube’s core engineering team leader, if a user can click a video and it starts to play within 200 milliseconds, the user will perceive it as being essentially instant. That’s the goal. With a service like Netflix or HBO Go, users don’t mind waiting a minute or so for a video to cache (aka “start loading up”), because they’re about to watch something longer anyway.  YouTube, where the average video length is much shorter, can’t afford that to have users waiting like that. So, here’s what the King Kong of internet video is doing to abolish lag. The Best Thing Since Sliced Bread Is Sliced Bread One recent change, which you may have already noticed, is the way in which videos are broken up for delivery. In ye olde days of YouTube (like, early last year), an uploaded video would be copied into different resolutions, such as 360p, 480p, 720p, and 1080p. Each of those was one, big, whole file. You’d click the video, and your computer would start downloading that file, and hopefully your internet connection was fast enough that the streaming wouldn’t catch up with the downloading, which would result in that dreaded pause for rebuffering. You could toggle between resolutions, but you were still downloading files in one big chunk.

 Things have worked differently now ever since YouTube integrated a technique it calls Sliced Bread back in April of 2012. Now, when someone uploads a video, it still gets copied into different resolutions, but each copy is like a loaf of bread which has been sliced. So you’ve got your 360p loaf, your 720p loaf, your 1080p loaf, etc. This enables YouTube to serve up your video one slice at a time, and it can change the quality of the next slice of video dynamically, depending on what’s happening with your internet connection. For example, when you first click the video it might start you with a couple slices from the 480p loaf, just to get your video playing right away. Once YouTube sees that you’ve got a steady and fast internet connection, the next slices could come from the 1080p loaf, giving you a boost in video quality. Then, suddenly, your significant other starts download some four terabyte PDF file and you lose a bunch of bandwidth; the next few slices could come at 720p. Ideally, the transitions are seamless. You might notice variation in the resolution, but there won’t be any pauses, if everything works correctly.

 Sliced Bread has been a success, so far, reducing the rebuffering of videos by 40 percent, YouTube claims. But it’s what’s coming down the pipe that should really kick things into high gear.  Parallel Processing and Pre-Loading Harding explains this very clearly at the white board in the video above, but here’s a summary for those of you at work. Currently, when you click on a YouTube video, first the watch page loads (the webpage that the video sits on). Then the javascript that controls that page is downloaded, then the video player, and then the video itself starts downloading. Once that happens streaming can start, but your newborn has also gotten its drivers license by then. So it’s being sped up on three pillars.

 Parallel. The first step to speeding up playback is doing more of the above-mentioned steps in parallel so that the process takes less time. You click the video, you still download the page, but then it will start downloading the javascript, the CSS, and the player simultaneously. Then it requests the video, and starts playing it back. Better, but we’re not talking about a huge amount of time savings here. Do Less. It’s when you transition from one video to another that you start to see significant reductions. If you’ve already watched a video, and in doing so downloaded the video player and all of that other stuff, why download it all over again? That’s how it works now, and it’s a total waste of time, The YouTube of the very near future knows that. So, instead, when you click over to another video, it will download the page, and immediately request the video and begin streaming because the player is already loaded up. Now we’re cooking with gas.

  Preloading Content. YouTube claims that people don’t generally just watch one video and leave. They have a tendency to click the related/suggested videos. Since YouTube thinks you’re likely to click on one of those videos next, it will pre-download the first slices (remember “Sliced Bread”) of some related videos. So, when you click over to one of those videos it has started caching, it should load almost instantly. In the video above, you can see it working in a prototype version of new YouTube. The video, which took one and a quarter seconds to load in the current software, began playback in less than half a second in the prototype software. This was on Google’s super fast office network, but the improvement should be even more stark with consumer home internet speeds. Now, it’s important to mention that this last step hinges on the idea that YouTube can accurately predict what you’re going to click next. Personally, I probably click on the Suggested videos mmmmaaaybe four percent of the time, but it does happen, and I’m sure it happens more for other people. Luckily, the Suggested results will get better if you’re within a channel, assuming you’re interested in watching other videos by the same content creator.

 It’s also worth mentioning that the biggest gap between hitting play and watching you video—preroll ads—aren’t going away any time soon. Still, faster is as faster does.  Going Mobile All these speedy changes would be even more appreciated if they were on mobile devices, where data speeds can often be slow and unreliable, and thankfully that’s just what’s happening. Users of YouTube’s Android app may have already noticed this, but in the settings there is now a page for Preloading. Tick those boxes and new videos from your subscribed channels and videos you add to your Watch Later list will pre-cache to your device behind the scenes. So, later, when you pull out your phone and fire up one of the videos with the little green arrows on it, it will begin to play almost instantly, and in full HD, no matter how slow you connection is. You can even jump around within the video and no reloading is required.

 This is a fantastic feature. The only problem is that you need to have some kind of internet connection to play the videos back. It would be even better if you could load up the video at night while on your home Wi-Fi network, and then watch them while you’re on the subway in the morning. But no, YouTube needs to check to make sure the content is still available and accessible to you, so it needs to perform at least a little tiny check in. Plus, and not insignificantly, it needs the internet to serve you ads. Hopefully they’ll find a way around this soon. Availability On the mobile side of things, preloading is currently only available on Android, but it should be coming to iOS soon. The desktop magic is very sooner. We were told it could be rolling out as early as Thursday of this week, or possibly closer to July 4th. We’ll update when we hear it’s gone live. These are all steps in the right direction. Naturally, home network speed affects this stuff a lot, but all things being equal, the speed is one of the major determining factors of the quality of user experience. It’s good to see that things are happening behind the scenes to move us toward the dream of honest-to-goodness instant.

  Big thanks to Google’s John Harding and Matt McLernon for their time.
                          