Review cards · 22 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. You shard a nearby-people index by location, grouping map cells into geoshards. How should the cells be grouped so no geoshard runs hot? medium Multiple choice
  9. Which query gets much more expensive if you partition by a hash of the key instead of by key range? medium Multiple choice
  10. 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
  11. A search index is split into 3 shards with no replicas, and queries are growing past what the cluster can serve. Its size is fine. What should you add? medium Multiple choice
  12. How does a Snowflake id fit time, worker and sequence into 64 bits? medium Flashcard
  13. Sensor readings are range-partitioned by timestamp. Why does one shard take all the writes, and what is the fix? medium Flashcard
  14. A document app stores pages as blocks. Most requests load many blocks of one workspace. Which partition key fits? medium Multiple choice
  15. 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
  16. 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
  17. Why create many more logical shards than machines, such as 480 logical shards on 32 databases? hard Flashcard
  18. A user flies to another city, so their new location belongs to another geoshard. What does the indexer do, and how do you stop two quick moves from being applied in the wrong order? hard Flashcard
  19. A dating app's user index is split into 7 shards by hash of user id and takes 6,000 nearby searches a second. How many searches a second does each shard serve? hard Estimate
  20. How do you move a shard's data to a new machine without stopping writes? hard Flashcard
  21. A Snowflake id generator sees its clock jump backwards by 50 ms. What should it do? hard Multiple choice
  22. Why does consistent hashing give each server many virtual nodes on the ring instead of one position? hard Multiple choice

More topics