Bitpath

Lesson 1 · Unit 03

Shards

Range or hash, and which key to split on

12 exercisesabout 3 min

What you practise

  • Range vs hash partitioning, hot keys and skew, choosing a partition key, why cross-shard queries and transactions hurt

Try a question from this lesson

Pick one

A users table has 2 billion rows, and one machine holds 500 million comfortably. You already replicate to 3 machines. Does that solve the size problem?

The idea

Concept cards are short on purpose. In the app they appear between questions, after you have met the idea.

Concept

Shards

Partitioning, or sharding, splits the data so each machine holds only a part: a shard. A key's shard is decided by a rule everyone can compute.

Range partitioning cuts the sorted keys into intervals. Hash partitioning hashes the key and takes the remainder by the number of shards.

Each shard is then replicated, as in the last unit.

range:  [a-f] [g-m] [n-s] [t-z]

hash:   hash(key) % 4  ->  shard 0..3

10 more exercises in the app

  • 3× type the answer
  • 4× multiple choice
  • 1× fill the blanks
  • 1× true or false
  • 1× match the pairs

Bitpath is an iOS app in development. Join the waitlist and you get one email when it is ready to try.

One email when Bitpath is ready to try. Nothing else. Privacy