The Power of Both Choices: Practical Load Balancing for Distributed Stream Processing Engines

Muhammad Anis Uddin Nasir, Gianmarco De Francisci Morales, David García-Soriano, Nicolas Kourtellis, Marco Serafini · DOI

In the world of big data, Distributed Stream Processing Engines (DSPEs) like Apache Storm and Samza are the workhorses that handle massive, never-ending flows of information. But these systems have a "hot key" problem: in real-world data, a few keys (like the word "the" in a Twitter stream) appear far more often than others. This leads to massive load imbalances where one worker is overwhelmed while others sit idle.

A team of researchers from KTH Royal Institute of Technology, Yahoo Labs, and QCRI have proposed a elegant solution called Partial Key Grouping (PKG). By adapting a classic randomized algorithm to the distributed streaming world, they’ve found a way to achieve near-perfect load balance with minimal overhead.

TL;DR

Partial Key Grouping (PKG) solves the load imbalance caused by skewed data in stream processing by allowing each key to be processed by two candidate workers instead of just one. By using local load estimation and the "power of two choices," PKG improves throughput by up to 60% and reduces latency by 45% compared to standard hashing.

What Problem Does This Paper Address?

Most DSPEs use Key Grouping (hashing) to ensure all messages with the same key go to the same worker. This is essential for stateful operations (like counting occurrences of a specific word). However, real-world data is rarely uniform; it usually follows a Zipfian distribution where a tiny fraction of keys accounts for a huge portion of the traffic.

As shown in Figure 1, standard key grouping sends all "orange" messages to one worker. If "orange" is a very popular key, that worker becomes a bottleneck.

Fig. 1: Load imbalance generated by skew in the key distri- bution when using key grouping. The color of each message represents its key.

Existing alternatives like Shuffle Grouping (round-robin) provide great balance but destroy the ability to easily manage state, as a single key's data is scattered across all workers, leading to massive memory and aggregation overhead.

Methods

The authors introduce Partial Key Grouping (PKG), which leverages two main innovations:

  1. Key Splitting: Instead of mapping a key to one worker, PKG uses two independent hash functions to identify two candidate workers for every key. When a message arrives, the system sends it to whichever of the two candidates is currently less loaded.
  2. Local Load Estimation: In a distributed system, knowing the "global" load of every worker is expensive and requires constant coordination. The authors prove that it is sufficient for each data source to track only the load it has sent to each worker. If every source balances its own output locally, the global system naturally reaches a balanced state.

This approach brings the "power of two choices"—a well-known concept in load balancing theory—into the practical, high-throughput world of distributed streaming.

Datasets

The researchers evaluated PKG using a mix of real-world and synthetic workloads:

  • Wikipedia (WP): A log of page visits (22M messages, 2.9M keys).
  • Twitter (TW): A word stream from 1.2 billion tweets.
  • Cashtags (CT): Stock market ticker symbols from Twitter, used to test "drift" (changing key popularity over time).
  • Synthetic (LN1, LN2): Log-normal distributions emulating social network workloads.
  • Graph Datasets: LiveJournal and Slashdot graphs to test robustness against source-side skew.

Key Insights and Ideas

  • Relaxing the Constraint: The "aha" moment is realizing that we don't need to send a key to only one worker. Sending it to two workers is a sweet spot: it provides enough flexibility to balance the load perfectly while keeping the memory overhead for stateful operations constant (only 2x) rather than linear with the number of workers.
  • Local is Enough: The proof that local load estimation works without inter-source communication is a major win for scalability. It allows PKG to be implemented with virtually zero coordination overhead.
  • Simplicity: PKG is remarkably easy to deploy. The authors implemented it in Apache Storm with less than 20 lines of code.

Key Results

The results across various datasets were dramatic. As seen in Figure 2, PKG (labeled 'G' and 'L') reduces the fraction of imbalance by several orders of magnitude compared to standard hashing ('H').

Figure 2: Fraction of average imbalance for different datasets and worker counts.
  • Throughput & Latency: In real Storm cluster deployments, PKG achieved up to a 60% increase in throughput and a 45% reduction in latency compared to standard key grouping.
  • Memory Efficiency: Compared to Shuffle Grouping, PKG used significantly less memory for stateful applications because it limits each key to only two workers.
  • Robustness: The system handled "concept drift" (where different keys become popular over time) gracefully, maintaining balance even as the underlying data distribution shifted.

Limitations and Future Work

While powerful, PKG is not a universal fix. It is specifically designed for associative and commutative operations (monoids)—tasks like counting, summing, or finding min/max values where partial results from two workers can be easily merged later. It cannot be directly applied to non-associative tasks, such as calculating the exact median of a stream.

The authors suggest future work could explore whether similar balance can be achieved without losing the "atomicity" of processing a key in a single location, or how to make more complex rebalancing schemes practical for DSPEs.

Summary updated

BibTeX
@inproceedings{nasir2015power,
  author = {Muhammad Anis Uddin Nasir and Gianmarco De Francisci Morales and David García-Soriano and Nicolas Kourtellis and Marco Serafini},
  title = {{The Power of Both Choices: Practical Load Balancing for Distributed Stream Processing Engines}},
  booktitle = {ICDE},
  year = {2015},
  url = {https://openreview.net/forum?id=nr8PxIS3whW},
}
Figure