Tech●●●●●Difficulty 4 of 5

How do you split a database too big for one machine?

Google's Bigtable cuts its tables into pieces of a few hundred megabytes to a few gigabytes, and thousands of servers each look after some of them.

▶ Start the story

When a database is too big for one machine, you cut it into pieces and give each piece to a different machine. Each piece is called a shard: a , meaning the rows of a table are divided up, each shard on its own database server. Instead of one giant table, you have many smaller ones, each in charge of its own slice of the data.

The splitting pays off twice. Since each server holds fewer rows, its indexes are smaller, which generally makes searching faster. And the work is shared across a large number of machines, which can significantly improve performance. The cut can follow real-world lines, such as European versus American customers, so the system can tell which shard to ask and query only that one.

From one big table to shards
  1. Step 1: One huge table

    Too big for a single machine

  2. Step 2: Cut by rows

    At chosen keys, such as a customer region

  3. Step 3: One shard per server

    Each holds its own slice

  4. Step 4: Find the shard

    Ask only the server that has your row

Google's Bigtable does this on a huge scale. It splits its tables at certain row keys into of a few hundred megabytes to a few gigabytes, and hundreds to thousands of servers share thousands to hundreds of thousands of tablets. It is built so you can add machines and let the system start using them without .

few hundred MB

to a few gigabytes: the size of each Bigtable tablet, with thousands to hundreds of thousands of them served by hundreds to thousands of servers

But in practice, sharding is complex. The aim is to minimize the need for cross-shard access, because a query that must visit many shards loses the benefit. Small tables are simply copied in full onto every server. Choosing how to cut matters too, and tools such as help spread large loads across servers.

Quiz me

0/3

  1. 1.Why does splitting a table across servers often make searches faster?
  2. 2.What is the main goal when designing how to shard a database?
  3. 3.What does Bigtable do when a table gets large?

Recap

Shard by cutting rows into independent pieces on different machines, and keep queries from needing many pieces at once.

💡 A trick to remember it · One encyclopedia, many volumes, many shelves: a shard is a volume, and a good cut means you only need one.

Surprising fact · Bigtable cuts tables into tablets of a few hundred megabytes to a few gigabytes, served by hundreds to thousands of servers.

Sources (3)

No source, no claim. Every fact in this lesson (16 claims) cites at least one of these.

  1. [1]Shard (database architecture) · Wikipedia
  2. [2]Bigtable · Wikipedia
  3. [3]Spanner (database) · Wikipedia
More lessons in 💻 Tech (3) See all tech lessons →

One more light on your map.

Get one lesson like this every day, about the things you love. Free, in two or five minutes.

Get the share card for this lesson ↗