Part 5 of 5 · 4 min read
Exercises
Easy
Easy 1: Define partitioning (15 minutes)
State, in one sentence, what partitioning does to a dataset.
Done when: splitting a dataset across multiple machines, each holding only a portion of the total, is correctly described.
Hint
It splits a dataset across multiple machines, each holding only a portion of the total data.
Easy 2: Name the two partitioning strategies (15 minutes)
Name the two partitioning strategies covered on this page.
Done when: range partitioning and hash partitioning are both correctly named.
Hint
Range partitioning and hash partitioning.
Easy 3: Define a hot partition (15 minutes)
State what a hot partition is.
Done when: a partition receiving a disproportionate share of reads or writes due to skew is correctly described.
Hint
A partition receiving a disproportionate share of reads or writes because of skew.
Medium
Medium 1: Choose a strategy for a range-query-heavy workload (25 minutes)
A table is almost always queried by a range of dates, such as "all orders from March." Recommend a partitioning strategy.
Done when: range partitioning is recommended, correctly reasoning that it keeps a queried date range on few partitions, making the common query efficient.
Hint
Range partitioning, since it keeps a queried date range together on few partitions.
Medium 2: Identify the skew risk in that choice (25 minutes)
Using the same table from the previous exercise, identify what skew risk arises if the table is also written in strict date order.
Done when: a hot partition on whichever partition covers the current date range is correctly identified, since all new writes land there.
Hint
A hot partition on whichever partition covers the current date, since date-ordered writes all land on the same place.
Medium 3: Choose a strategy for a lookup-heavy workload (30 minutes)
A table is almost always queried by looking up one exact customer ID at a time, never by a range of IDs. Recommend a partitioning strategy.
Done when: hash partitioning is recommended, correctly reasoning that range queries are not needed here, so the even load distribution hash partitioning provides outweighs its range-query cost.
Hint
Hash partitioning, since range queries are not needed and even load distribution across partitions matters more here.
Hard
Hard 1: Diagnose a real skew scenario (30 minutes)
A video platform partitions videos by uploader ID. One creator's videos go viral and receive a huge spike in views. Explain what happens to that creator's partition, and propose one mitigation.
Done when: the explanation correctly identifies that creator's partition as a hot partition under the sudden read load, and proposes a reasonable mitigation, such as further splitting that one popular uploader's data across more than one partition or adding a cache in front of it.
Hint
That creator's partition becomes a hot spot under the view spike; splitting their data across more partitions or adding a cache in front of it are reasonable mitigations.
Hard 2: Compare the two strategies on a mixed workload (35 minutes)
A table needs both efficient range queries on a date column and even load distribution. Explain why neither pure range partitioning nor pure hash partitioning satisfies both needs, and propose an approach that gets closer.
Done when: the explanation correctly identifies that pure range partitioning risks hot spots on sequential dates while pure hash partitioning scatters range queries, and proposes a reasonable compromise, such as partitioning by a hash of a secondary key combined with the date, or range partitioning by date while hashing within each date range.
Hint
Pure range partitioning risks hot spots on sequential dates, and pure hash partitioning scatters range queries; a compromise such as hashing within date ranges, or partitioning by date while hashing a secondary key, gets closer to both goals.
Hard 3: Justify a partitioning key choice with reasoning, not just a label (40 minutes)
A messaging application partitions conversations by conversation ID, using hash partitioning. Explain why this choice is likely reasonable, considering both the typical access pattern, looking up one conversation at a time, and the typical skew risk, a small number of extremely active group conversations.
Done when: the explanation correctly notes that hash partitioning fits the lookup-by-single-ID access pattern well, while also correctly noting that a small number of extremely active conversations could still create localized hot spots even under hash partitioning, since hashing distributes keys evenly but does not reduce how much load one single, very active key generates.
Hint
Hash partitioning fits a lookup-by-single-ID pattern well, but it only spreads different keys evenly; it does nothing to reduce the load any one single, very active key generates, so a few extremely active conversations could still create localized hot spots.