Review cards · 18 cards

Sharding

Splitting data across machines: partition keys, consistent hashing and hot partitions.

Train sharding in daily review

Cards

  1. Placing each user's data in a region near them, which also helps meet data-residency laws, is called _____. easy Fill in the blank
  2. You store 60 TB of data with 3 replicas of everything, and each node can hold 4 TB. How many nodes do you need, ignoring headroom? easy Estimate
  3. Peak load is 120,000 writes/s. One primary can safely take 8,000 writes/s. How many shards do you need? easy Estimate
  4. A Snowflake generator has a 12-bit sequence per millisecond. At most how many ids can one worker issue per second? easy Estimate
  5. Why use consistent hashing instead of hash(key) % N to pick a shard? medium Flashcard
  6. Two tables you often join end up on different shards. What are your options? medium Flashcard
  7. What makes a good partition key? medium Flashcard
  8. Which query gets much more expensive if you partition by a hash of the key instead of by key range? medium Multiple choice
  9. A query that cannot be routed by the partition key is sent to every shard and the results merged. This is a _____ query, and its latency is set by the _____ shard. medium Fill in the blank
  10. How does a Snowflake id fit time, worker and sequence into 64 bits? medium Flashcard
  11. Sensor readings are range-partitioned by timestamp. Why does one shard take all the writes, and what is the fix? medium Flashcard
  12. A document app stores pages as blocks. Most requests load many blocks of one workspace. Which partition key fits? medium Multiple choice
  13. Users are sharded by user_id, and you add a global secondary index on email, itself partitioned by email. What do you pay for fast email lookups? hard Multiple choice
  14. You shard view counts by video_id. One viral video now gets 200,000 writes a second, far more than one shard can take. What is the usual fix? hard Multiple choice
  15. Why create many more logical shards than machines, such as 480 logical shards on 32 databases? hard Flashcard
  16. How do you move a shard's data to a new machine without stopping writes? hard Flashcard
  17. A Snowflake id generator sees its clock jump backwards by 50 ms. What should it do? hard Multiple choice
  18. Why does consistent hashing give each server many virtual nodes on the ring instead of one position? hard Multiple choice

More topics