Partitioning (sharding)

Spreading a database too large for one server: choosing the partition key, by range or by hash, avoiding hot partitions, rebalancing, and knowing when not to do it.

  • 32 cards
  • 3 topics
  • Free

The outline, topic by topic

Each topic is weighted the way the exam weighs it.

  1. Concepts
  2. Scenarios
  3. Trade-offs and failures

A few cards from the deck

  • Sharding: what is it?

    Show the answer

    Spreading a table's rows over several servers, each holding only part of them.

    Writes and volume are shared between servers.

  • Writes exceed what one server can absorb, and replicas are already in place. What do you do?

    • Shard
    • Add replicas
    • Add a cache
    • Lengthen transactions
    Show the answer

    Shard

    Only splitting the data between servers also splits the writes.

  • Partition key: what is it?

    Show the answer

    The field whose value decides which partition a row goes to.

    It decides everything: spread, fast queries, costly queries.

  • A transaction touches two partitions. How is that?

    • Hard and slow: it needs coordination between servers
    • As simple as before
    • Impossible to run
    • Faster
    Show the answer

    Hard and slow: it needs coordination between servers

    A good partition key avoids needing it.