CS FundamentalsHardProduct-company placement · system design

A table of user events is sharded by event date, and all writes for today land on one shard, which is overloaded while others sit idle. What is the best change?

  1. A. Add more shards but keep event date as the key
  2. B. Shard by a well-spread key, such as hashed user ID
  3. C. Move the hot shard onto a server with faster disks
  4. D. Add a global secondary index on the date column

Correct answer: B. Shard by a well-spread key, such as hashed user ID

A monotonically increasing key such as a date or timestamp sends every new write to one partition. Hashing a high-cardinality key spreads writes; more date shards still put all of today on one of them.

More Software Engineering, Git and Cloud Basics questions

Exams that ask this topic