Data Modeling hard
Your 'Orders' table is partitioned by `customer_id`. One customer is responsible for 20% of all orders (Data Skew). How do you resolve the write hotspot?
- A Horizontal CPU Verticalization, where the database automatically migrates the 'whale' customer to a much larger and more powerful physical instance within the cluster.
- B Salting the Partition Key by appending a random suffix (e.g., 1..N) to the ID, spreading that single customer's data across multiple physical partitions for parallel writing.
- C Global Sequential Numbering, which replaces the existing partition key with a strictly monotonic auto-incrementing integer that is synchronized across all regional data centers.
- D Write-Buffer Caching, which leverages a specialized, ultra-high-speed memory layer to absorb the bursty write volume before eventually flushing the data to the physical disk.
Answer: B. Salting the Partition Key by appending a random suffix (e.g., 1..N) to the ID, spreading that single customer's data across multiple physical partitions for parallel writing.
In distributed databases, a single partition has a hard throughput limit (e.g., 3000 WCU in DynamoDB). If one customer produces too many orders, the partition becomes 'hot' and throttled. 'Salting' the key (e.g., storing `User123#1`, `User123#2`, etc.) allows you to use the full power of the cluster. The trade-off is 'Read Complexity': to find all orders for that customer, your application must now query all N 'salted' partitions and merge the results.
One system design question a day, with spaced repetition so the ones you miss come back.
Get the appRelated questions
- When modeling a Distributed Transaction using the Saga Pattern (Choreography or Orchestration), what type of consistency do you achieve?
- Which practice prevents SQL Injection attacks?
- What is 'Bi-Temporal' data modeling (e.g., in SQL:2011 standard)?
- Adding an Index to a database column generally improves Read performance. What is the negative trade-off?
- Log Systems Merge (LSM) Trees (used in RocksDB, Cassandra) optimize for fast writes. What is their primary downside regarding Disk I/O?
- What is the primary objective of normalizing a relational database schema (e.g., to 3NF)?