Core Concepts
Pinterest successfully scaled its platform to 11 million users with only 6 engineers by adopting a pragmatic, phased approach to architecture simplification and horizontal scaling.
Abstract
The article discusses how Pinterest scaled its platform from 0 to 10s of billions of page views per month in just two years, despite having a small engineering team of only 6 people. The scaling journey can be divided into four distinct phases:
The Age of Finding Yourself: This phase was characterized by rapid prototyping and evolving product requirements, managed by a small engineering team.
The Age of Experimentation: Exponential user growth demanded rapid scaling, leading to the adoption of numerous technologies. However, this resulted in a complex, fragile system.
The Age of Maturity: This phase involved a conscious simplification of their architecture, focusing on mature, scalable technologies like MySQL, Memcache, and Redis. Instead of adding to the tech stack, Pinterest invested the money into growing what was working well.
The Age of Return: With the right architecture in place, Pinterest continued its growth trajectory simply by scaling horizontally, validating its choices.
The core technologies that Pinterest relied on were MySQL, Memcache, and Redis. These were chosen for their reliability, scalability, and ease of maintenance. Pinterest also had to make a critical choice between database clustering and sharding. They ultimately opted for sharding due to the complexity and issues they faced with clustering during the "Age of Experimentation."
The migration to a sharded architecture was a phased process, which involved eliminating database joins, denormalizing data, and implementing aggressive caching. This approach allowed for incremental implementation and thorough validation at each stage.
While sharding offered a more manageable approach, it came with its own challenges, such as scripting for data migration, implementing application-level logic for data consistency, and reporting across multiple shards. Pinterest addressed these challenges through careful planning and the development of robust tooling.
The key takeaways from Pinterest's scaling journey include the importance of simplicity, prioritizing scalability over database features, and designing for horizontal growth. By embracing these principles, Pinterest was able to successfully navigate the challenges of explosive user growth with a small engineering team.
Stats
Pinterest scaled to 11 million users with only 6 engineers.
Pinterest grew from 0 to 10s of billions of page views per month in just two years.
Quotes
"In one case they bring in a new secondary. At about 80% the secondary says it's primary and the primary goes to secondary and you've lost 20% of the data. Losing 20% of the data is worse than losing all of it because you don't know what you've lost."
"All data (pins, boards, etc) for a user is collocated on the same shard. Huge advantage. Rendering a user profile, for example, does not take multiple cross shard queries. It's fast."