How YouTube scales its massive MySQL databases
Ever wondered how YouTube scales its massive MySQL databases? I was watching NeetCode โHow to Design YouTubeโ video, and one thing completely blew my mind โ
๐๐ผ๐ผ๐ด๐น๐ฒ ๐๐๐ฒ๐ ๐ ๐๐ฆ๐ค๐ ๐๐ผ ๐๐๐ผ๐ฟ๐ฒ ๐บ๐ฒ๐๐ฎ๐ฑ๐ฎ๐๐ฎ.
๐๐ถ๐ต ๐ฉ๐ฆ๐ณ๐ฆโ๐ด ๐ต๐ฉ๐ฆ ๐ต๐ธ๐ช๐ด๐ต โ ๐ต๐ฉ๐ฆ๐บ ๐ฅ๐ฐ๐ฏโ๐ต ๐ถ๐ด๐ฆ ๐ฑ๐ญ๐ข๐ช๐ฏ ๐๐บ๐๐๐. ๐๐ฉ๐ฆ๐บ ๐ถ๐ด๐ฆ ๐๐ช๐ต๐ฆ๐ด๐ด โ ๐ข๐ฏ ๐ฐ๐ฑ๐ฆ๐ฏ-๐ด๐ฐ๐ถ๐ณ๐ค๐ฆ, ๐ด๐ฉ๐ข๐ณ๐ฅ๐ช๐ฏ๐จ ๐ฎ๐ช๐ฅ๐ฅ๐ญ๐ฆ๐ธ๐ข๐ณ๐ฆ ๐ง๐ฐ๐ณ ๐๐บ๐๐๐ ๐ต๐ฉ๐ข๐ต ๐ฎ๐ข๐ฌ๐ฆ๐ด ๐ช๐ต ๐ฎ๐ข๐ด๐ด๐ช๐ท๐ฆ๐ญ๐บ ๐ด๐ค๐ข๐ญ๐ข๐ฃ๐ญ๐ฆ.
Vitess basically acts as a layer between your app and multiple MySQL instances, handling:
โข Sharding (splitting data across servers) โข Connection pooling โข Query routing โข Failover and replication
๐ช๐ต๐ฎ๐โ๐ ๐ฒ๐๐ฒ๐ป ๐ฐ๐ผ๐ผ๐น๐ฒ๐ฟ โ ๐ฉ๐ถ๐๐ฒ๐๐ ๐ถ๐ ๐ฐ๐น๐ผ๐๐ฑ-๐ป๐ฎ๐๐ถ๐๐ฒ.
You can deploy it with Kubernetes, and since it doesnโt rely on local storage, your data isnโt tied to any one pod.
Even if a pod shuts down, Vitess ensures durability โ as long as one replica remains alive, your committed transactions are safe.
Itโs used by giants like YouTube, and the engineers say โ
โOnce you start sharding, it becomes addictive.โ ๐
Despite its scale, Vitess adds just about 0.2 milliseconds of static overhead โ incredibly efficient.
https://lnkd.in/gaMSEhR7 Amazing explaination https://lnkd.in/gqY8-5MN
There are now efforts to bring Vitess-like scaling to PostgreSQL too
๐ ๐๐น๐๐ถ๐ด๐ฟ๐ฒ๐ โ โ๐ฉ๐ถ๐๐ฒ๐๐ ๐ณ๐ผ๐ฟ ๐ฃ๐ผ๐๐๐ด๐ฟ๐ฒ๐โ ๐๐ญ๐ข๐ฏ๐ฆ๐ต๐๐ค๐ข๐ญ๐ฆโ๐ด ๐๐ฆ๐ฌ๐ช โ ๐ข ๐ฏ๐ฆ๐ธ ๐ด๐ฉ๐ข๐ณ๐ฅ๐ช๐ฏ๐จ ๐ด๐ฐ๐ญ๐ถ๐ต๐ช๐ฐ๐ฏ ๐ง๐ฐ๐ณ ๐๐ฐ๐ด๐ต๐จ๐ณ๐ฆ๐ด, ๐ฃ๐ถ๐ช๐ญ๐ต ๐ง๐ณ๐ฐ๐ฎ ๐ต๐ฉ๐ฆ ๐จ๐ณ๐ฐ๐ถ๐ฏ๐ฅ ๐ถ๐ฑ. ๐๐ข๐ต๐ข๐ฃ๐ข๐ด๐ฆ๐ด ๐ข๐ณ๐ฆ ๐ฆ๐ท๐ฐ๐ญ๐ท๐ช๐ฏ๐จ ๐ง๐ข๐ด๐ต โ ๐ข๐ฏ๐ฅ ๐ช๐ตโ๐ด ๐ธ๐ช๐ญ๐ฅ ๐ต๐ฐ ๐ด๐ฆ๐ฆ ๐ฉ๐ฐ๐ธ ๐ต๐ฐ๐ฐ๐ญ๐ด ๐ญ๐ช๐ฌ๐ฆ ๐๐ช๐ต๐ฆ๐ด๐ด ๐ฎ๐ข๐ฌ๐ฆ โ๐ช๐ฏ๐ง๐ช๐ฏ๐ช๐ต๐ฆ ๐ด๐ค๐ข๐ญ๐ฆโ ๐ข ๐ณ๐ฆ๐ข๐ญ๐ช๐ต๐บ ๐ฐ๐ฏ ๐ต๐ฐ๐ฑ ๐ฐ๐ง ๐จ๐ฐ๐ฐ๐ฅ ๐ฐ๐ญ๐ฅ ๐๐บ๐๐๐.