scorecardHow We Scaled Pinterest From Zero Users To A $2 Billion Valuation
  1. Home
  2. tech
  3. How We Scaled Pinterest From Zero Users To A $2 Billion Valuation

How We Scaled Pinterest From Zero Users To A $2 Billion Valuation

Here we go!

How We Scaled Pinterest From Zero Users To A $2 Billion Valuation

How We Scaled Pinterest From Zero Users To A $2 Billion Valuation

How We Scaled Pinterest From Zero Users To A $2 Billion Valuation

Pinterest is a social network with boards of people's favorite things.

Pinterest is a social network with boards of people

You can follow pins and boards from people you know.

You can follow pins and boards from people you know.

Here, you can see the pins from everyone you follow.

Here, you can see the pins from everyone you follow.

So users have boards and relationships.

So users have boards and relationships.

Here's Pinterest's page view count at the beginning.

Here

In March 2010, the team wasn't working with much from an infrastructure point of view.

In March 2010, the team wasn

Nine months later...

Nine months later...

The product and architecture evolved.

The product and architecture evolved.

Pinterest started doubling page views every month and a half, but everything was breaking.

Pinterest started doubling page views every month and a half, but everything was breaking.

So they ended up with five major technologies just for the data alone.

So they ended up with five major technologies just for the data alone.

How We Scaled Pinterest From Zero Users To A $2 Billion Valuation

How We Scaled Pinterest From Zero Users To A $2 Billion Valuation

So they started dropping off technologies and did a massive restructuring of the architecture.

So they started dropping off technologies and did a massive restructuring of the architecture.

Here's what they changed the architecture to.

Here

Pinterest's web traffic continued to increase.

Pinterest

Pinterest started to put more resources into its architecture to handle its growth.

Pinterest started to put more resources into its architecture to handle its growth.

Pinterest uses Amazon EC2/S3 for a few reasons. The main one: you can have new instances ready in a matter of seconds.

Pinterest uses Amazon EC2/S3 for a few reasons. The main one: you can have new instances ready in a matter of seconds.

But there is limited choice.

But there is limited choice.

How We Scaled Pinterest From Zero Users To A $2 Billion Valuation

How We Scaled Pinterest From Zero Users To A $2 Billion Valuation

Open source database MySQL has proven to be solid choice for Pinterest. It's incredibly mature and you can hire for it, as lots of engineers know MySQL.

Open source database MySQL has proven to be solid choice for Pinterest. It

Memcache is also incredibly mature, and it never crashes.

Memcache is also incredibly mature, and it never crashes.

Redis isn't very mature, but it's simple.

Redis isn

Pinterest realized that during its rapid growth, it needed to spread the data evenly to handle the load. So they defined a spectrum of options between clustering and sharding.

Pinterest realized that during its rapid growth, it needed to spread the data evenly to handle the load. So they defined a spectrum of options between clustering and sharding.

With clustering, everything is automatic.

With clustering, everything is automatic.

But sharding is a completely manual data placement process. It's used to separate databases into smaller, faster, and more manageable data pieces called shards.

But sharding is a completely manual data placement process. It

How We Scaled Pinterest From Zero Users To A $2 Billion Valuation

How We Scaled Pinterest From Zero Users To A $2 Billion Valuation

How We Scaled Pinterest From Zero Users To A $2 Billion Valuation

How We Scaled Pinterest From Zero Users To A $2 Billion Valuation

How We Scaled Pinterest From Zero Users To A $2 Billion Valuation

How We Scaled Pinterest From Zero Users To A $2 Billion Valuation

If there's a massive bug, it will impact every single node. A SPOF brought down Pinterest four times.

If there

How We Scaled Pinterest From Zero Users To A $2 Billion Valuation

How We Scaled Pinterest From Zero Users To A $2 Billion Valuation

How We Scaled Pinterest From Zero Users To A $2 Billion Valuation

How We Scaled Pinterest From Zero Users To A $2 Billion Valuation

With sharding, everything is manual. And that's a good thing.

With sharding, everything is manual. And that

If your project has a few terabytes of data, you should shard as soon as possible. When Pinterest's Pin table reached one billion rows, the indexes ran out of memory. That's when the company decided to shard.

If your project has a few terabytes of data, you should shard as soon as possible. When Pinterest

So Pinterest froze some of its features to start the transition from clustering to sharding.

So Pinterest froze some of its features to start the transition from clustering to sharding.

The less data you move, the more stable your architecture will be.

The less data you move, the more stable your architecture will be.

Since they wanted to shard on MySQL, they projected growth for next five years.

Since they wanted to shard on MySQL, they projected growth for next five years.

Pinterest initially put their databases on 8 physical servers.

Pinterest initially put their databases on 8 physical servers.

For high availability, Pinterest ran MySQL in multi master replication mode.

For high availability, Pinterest ran MySQL in multi master replication mode.

With an increased load on a database, Pinterest replicated a server to handle some of the data nodes.

With an increased load on a database, Pinterest replicated a server to handle some of the data nodes.

Since Pinterest is on AWS and MySQL queries took about 3 milliseconds, they decided to build the location into the ID.

Since Pinterest is on AWS and MySQL queries took about 3 milliseconds, they decided to build the location into the ID.

If Pinterest has 50 IDs, for example, they split them up and run them in parallel. This is what Pinterest's lookup/rendering structure looks like.

If Pinterest has 50 IDs, for example, they split them up and run them in parallel. This is what Pinterest

How We Scaled Pinterest From Zero Users To A $2 Billion Valuation

How We Scaled Pinterest From Zero Users To A $2 Billion Valuation

All of Pinterest's data falls into two categories: objects or mappings.

All of Pinterest

How Pinterest brings up a user profile. Most of the calls are served from the cache (Memcache or Redis)

How Pinterest brings up a user profile. Most of the calls are served from the cache (Memcache or Redis)

Pinterest built a huge scripting farm to move 500 million Pins and 1.6 billion follower rows. Scripting is what happens when you need to move from the old, unsharded system to the sharded one.

Pinterest built a huge scripting farm to move 500 million Pins and 1.6 billion follower rows. Scripting is what happens when you need to move from the old, unsharded system to the sharded one.

How We Scaled Pinterest From Zero Users To A $2 Billion Valuation

How We Scaled Pinterest From Zero Users To A $2 Billion Valuation

How We Scaled Pinterest From Zero Users To A $2 Billion Valuation

How We Scaled Pinterest From Zero Users To A $2 Billion Valuation

How We Scaled Pinterest From Zero Users To A $2 Billion Valuation

How We Scaled Pinterest From Zero Users To A $2 Billion Valuation

How We Scaled Pinterest From Zero Users To A $2 Billion Valuation

How We Scaled Pinterest From Zero Users To A $2 Billion Valuation

Need to give your brain a rest?

Need to give your brain a rest?

Advertisement