YouTube – How Connection Speed is Detected

youtube

When right-clicking on a YouTube video, open "Stats for nerds". You can see a column "Connection Speed" which, to my surprise, is usually correct. But how does it know?

A normal speedtest will of course show the maximum bandwidth, but YouTube is not doing that. "Network Activity" shows how much YouTube is really using (I confirmed that by another speed meter).

p.s., Youtube is not stress testing periodically; the "Connection Speed" updates in normal video playing.

The "Connection Speed" value is also correct on various pings. I tried VPN all over the world, from 10 ms to 400+ ms.

Best Answer

Generally, the way you measure connection speed is by having the user download a file (or files) of known size and measuring the time this takes. This gives you speed (i.e. data transferred over time). See "Checking someones bandwidth and loading content based on it" for a JavaScript implementation. Another example of this is fast.com, which is Netflix's speed test website. When I open my browser inspector on the page, I see it repeatedly requesting the same 25 MB file over and over again:

image of browser inspector showing list of requests being made by speed test

p.s., Youtube is not stress testing periodically; the "Connection Speed" updates in normal video playing.

In the case of YouTube, the video itself (or the parts that comprise it) is a file of known size and your browser is downloading it, so with that information, your connection speed can be determined.