liveBook · Manning

Partition imbalance

As explained in Latency

Partition imbalance is the uneven distribution of data-processing work across partitions, causing some partitions to be overloaded while others are underutilized.

Partition imbalance occurs when data-processing work is unevenly distributed across partitions. One partition might handle most incoming requests while others sit mostly idle. The overloaded partition can raise latency and limit throughput and scalability, even when the system has spare capacity elsewhere. section 5.5

Check two distinct sources of imbalance:

  • Data distribution: A low-cardinality partition key offers few values across which to spread data. If those values are also unevenly distributed, some partitions can be much larger. Skewed writes can enlarge them further. section 5.2.1
  • Access patterns: Requests can concentrate on a few hot partitions even when data is evenly distributed. Demand can also shift over time, making a previously balanced layout insufficient. section 5.5 section 5.5.2

An online store

User IDs offer many distinct partition-key values; order statuses such as pending and shipped offer only a few. Even with well-distributed product data, a launch can send many requests to the partition holding one new product. A sale can create a similar temporary hotspot. section 5.2.1 section 5.5.2

Start by examining the proposed key’s cardinality and the distribution of its values, then consider which partitions receive requests and writes. A high-cardinality key gives data more opportunities to spread out, but does not guarantee balanced traffic. For hot partitions, consider partitioning within them or assigning them more resources. Rebalance partitions that have grown disproportionately; for predictable demand spikes, consider overprovisioning, load balancing, or scaling partitions. The choice depends on whether the imbalance comes from stored data or changing demand. section 5.2.1 section 5.5.2

How Latency covers it

How deep it goes
Defines the failure mode, distinguishes its main causes, and discusses key selection and mitigations without a measurement procedure.
Examples
Contrasts user IDs with order statuses and illustrates changing demand through a product launch and a sale.
What it assumes
Assumes basic familiarity with database partitions while defining cardinality through concrete partition-key examples.
What you can do after
Evaluate/understand it by distinguishing data skew from access skew and choosing among rebalancing, added capacity, and load balancing.
How it connects
Connects partition imbalance to horizontal partitioning, partition-key cardinality, hot partitions, workload skew, load balancing, and scaling.

Also explained in

Compare how 2 books explain partition imbalance →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Latency. The section links point to the parts of the book it draws on.