Author | NK Planning | Yan Zheng February 2005, California, USA. PayPal, a world-renowned online payment service company, had been in existence for 6 years and 2 months. Three early employees began looking for their own opportunities as if they had discovered the traffic password of the Internet world. Finally, they wanted to build a platform for sharing videos. Later, this platform born in the garage became the famous YouTube. Initially, they had limited financial resources and could only raise funds for YouTube through credit card debt and infrastructure loans. However, financial constraints also forced them to build an excellent set of scalability technology. In the second year, the daily video playback volume of their platform reached 100 million. What’s more surprising is that they achieved this with only 9 engineers. How did YouTube do it? Here are the key design points of that year. (P.S.: At first glance, it looks plain and simple.) 1. Magic FlywheelThey use a "flywheel" approach to collect and analyze system data to facilitate scalability. Their workflow is a continuous cycle: identify bottlenecks → fix bottlenecks → drink water → sleep. The benefit of this approach is that it avoids the need for high-end hardware (no large-scale deployment) and reduces hardware costs. Scalability loop 2. A seemingly boring but ingenious technology stackThey keep their tech stack simple and use proven technologies. Their tech stack is definitely beyond your imagination: YouTube Technology Stack
3. Keep it simpleThey believed that software architecture is the root of scalability. They did not blindly pursue “buzzwords” to scale. Therefore, they kept the architecture simple — making code review easier. This allowed them to quickly re-architecture to meet changing requirements. For example, they pivoted from a dating site to a video sharing site. Additionally, they keep network paths simple because network devices have scalability limitations. Hardware Cost They also used commodity hardware. It enabled them to reduce power consumption and maintenance expenses and keep costs low. Furthermore, they keep scale-aware code relatively independent from application development. 4. Choose your main battlefieldThey outsourced many unimportant issues. Because they wanted to focus on important things. They didn't have the time or resources to build their own infrastructure to serve popular videos. So, they put popular videos on a third-party CDN. Benefits:
They serve less popular videos from co-located data centers, use software RAID to improve performance by accessing multiple disks in parallel, and tune their servers to prevent cache thrashing. They keep their infrastructure in co-located data centers for two reasons: First, they can easily adjust the servers to meet their needs. Second, it facilitates their contract negotiations. Choose your battleground; outsource issues to free up resources Each video has 4 thumbnails. Therefore, they faced problems in serving small objects: lots of disk seeks and file system limitations. Therefore, they put the thumbnails into BigTable. It is a distributed data store with many advantages: avoiding small file problem by clustering files, improved performance, multi-level cache low latency, easy configuration. They also falsify data to prevent expensive transaction fees. For example, they falsify video views and update the counter asynchronously. A popular technique for approximate correctness today is the Bloom filter, which is a probabilistic data structure. 5. Three pillars of scalabilityYouTube relies on three pillars of scalability: statelessness, replication, and partitioning. The 3 Pillars of Scalability They keep their network servers stateless and scale through replication. They replicated database servers for read scalability and high availability, and load-balanced traffic between the replicas. But this approach caused problems: replication lag and write scalability issues. Replication and Partitioning So they partitioned the database to improve write scalability, cache locality, and performance. It also reduced hardware costs by 30%. In addition, they studied data access patterns to determine the partitioning level. For example, they studied popular queries, joins, and transaction consistency and chose user as the partitioning level. 6. Solid engineering teamA knowledgeable team is a great asset for scalability. Interdisciplinary Team They keep the team size small to improve communication: just 9 engineers. Their team is very good at cross-disciplinary skills. 7. Don’t repeat yourselfThey use cache to prevent duplication of expensive operations. It enables them to scale pageviews. Multi-level cache can be expanded They also implemented caching at multiple levels - and reduced latency. 8. Sorting: Prioritize important indicatorsRank important traffic; 80/20 rule (Pareto principle) They prioritize video viewing traffic over all other traffic. Therefore, they reserve a dedicated resource cluster for video viewing traffic. This provides high availability. 9. Preventing “Thunder Groups”If many concurrent clients query the server, thundering herd problem will occur. It will degrade the performance. The Thundering Herd Problem They use jitter to prevent thundering problems. For example, they added jitter to cache expiration for popular videos. 10. Fight a protracted warThey focus on macro-level things: algorithms and scalability. They do quick hacks to buy more time to build long-term solutions. For example, using Python to eliminate bad APIs to prevent short-term problems. Risk and Reward They tolerate defects in components. When they encounter a bottleneck: they either rewrite the component or remove it. They trade efficiency for scalability. Here are four examples:
11. Adaptive evolutionThey adapted the system to suit their needs. Example:
Coding principles They didn’t waste time writing code to limit people. Instead, they adopted good engineering practices — coding conventions — to improve the structure of their code. --postscript--In November 2006, Google acquired YouTube for $1.65 billion and operates it as a subsidiary. Today, it remains the leader in the video sharing market, with 5 billion video views per day. According to Forbes, the net worth of YouTube's founder exceeds $100 million. YouTube became the leader in video search only 20 months after its creation, which can be said to have created a Silicon Valley miracle. Reference link: https://newsletter.systemdesign.one/p/youtube-scalability |
<<: Let's talk about HTTP/3, QUIC, how do they work?
>>: Stop guessing! Teach you how to accurately identify the indicator lights on box switches!
[Bangkok, Thailand, October 28, 2022] Recently, t...
HostKvm has launched new products, this time with...
This month, Megalayer provides Hong Kong Alibaba ...
A data center is a complex organization with many...
Changing the rules of the online market It’s safe...
Now no one asks "how far are we from 5G"...
Overview The HTTP status code is a 3-digit code u...
Today, the use and growth of mobile technology ha...
【Attention】This merchant has run away!!! Limewave...
With the rapid development of mobile devices, the...
Industry experts point out that 6G will achieve s...
[[325361]] According to foreign media reports, re...
"Three Gigabits" will be implemented in...
April 20, 2022 – The 2022 F5 Multi-Cloud Applicat...
Earlier this month, the blog shared information a...