Skip to content
System Designer

Scale the data · 3 minutes

Splitting data

When one database cannot take the writes, split the data across several.

Open this lesson
When one database cannot take the writes, split the data across several.

One database has a ceiling

A single database can only take so many writes, and replicas do not help. Sharding splits the data by a key, such as user id, so each shard holds a slice and takes only its share of writes.

Choosing the key

A partition field decides which records must stay together. Compare user ids with a country that holds most users.

Try the idea

Writes are far above what one database can do. Swap it for a sharded database.

Key numbers

One SQL primary
≈ 2,000 writes a second. approx.
Four shards
≈ 8,000 writes a second. if the key spreads evenly, approx.
Moving data to add shards
hours to days. plan ahead, approx.

Check your reasoning

Think through these questions before opening the lesson. In the game you can test the idea and compare your reasoning.

  • Sharding mainly helps with:
  • Which is the best shard key?
  • What gets harder after sharding?

The key point

Shard when writes or size outgrow one machine, and pick a key that spreads evenly.

Practise this idea

Continue through the lesson tracks