System-aware dynamic partitioning for batch and streaming workloads

Zoltán Zvara, Péter G. N. Szabó, Balázs Barnabás Lóránt, András A. Benczúr · DOI

Abstract

When processing data streams with highly skewed and nonstationary key distributions, we often observe overloaded partitions when the hash partitioning fails to balance data correctly. To avoid slow tasks that delay the completion of the whole stage of computation, it is necessary to apply adaptive, on-the-fly partitioning that continuously recomputes an optimal partitioner, given the observed key distribution. While such solutions exist for batch processing of static data sets and stateless stream processing, the task is difficult for long-running stateful streaming jobs where key distribution changes over time. Careful checkpointing and operator state migration is necessary to change the partitioning while the operation is running. Our key result is a lightweight on-the-fly Dynamic Repartitioning (DR) module for distributed data processing systems (DDPS), including Apache Spark and Flink, which improves the performance with negligible overhead. DR can adaptively repartition data during execution using our Key Isolator Partitioner (KIP). In our experiments with real workloads and power-law distributions, we reach a speedup of 1.5-6 for a variety of Spark and Flink jobs.

Introduction

In large-scale distributed data processing, work is typically distributed by hashing keys (such as UserIDs) to different worker nodes. While effective for uniform distributions, real-world data is frequently "skewed," where a small number of "heavy hitter" keys appear far more often than others. This imbalance leads to the "straggler problem," where a single overwhelmed worker delays the entire computation stage while others remain idle.

This challenge is intensified by "concept drift," where the distribution of heavy keys shifts over time. While static batch data can be rebalanced relatively easily, addressing skew in stateful streaming is complex. Moving a key to a new worker requires migrating its associated "state" (e.g., historical aggregates), which often incurs prohibitive network costs or requires stopping the job entirely.

The Dynamic Repartitioning (DR) Framework

To address these issues, we developed a lightweight, system-aware Dynamic Repartitioning (DR) module. The module consists of a Master (DRM) and Workers (DRW) that integrate directly into existing frameworks like Apache Spark and Flink.

The DR architecture integrates a Master (DRM) and Workers (DRW) into existing DDPS frameworks to manage local and global histograms for repartitioning.

The core of the DR module is the Key Isolator Partitioner (KIP), which employs a three-stage strategy:

  1. Heavy Hitter Detection: A low-memory sampling mechanism identifies frequent keys across the cluster.
  2. The KIP Algorithm: Instead of blind hashing, KIP explicitly routes heavy keys to specific partitions. It prioritizes keeping keys in their current partitions whenever possible to minimize state migration overhead.
  3. System Integration: By leveraging native system mechanisms—such as Spark’s Directed Acyclic Graph (DAG) and Flink’s checkpointing—DR can migrate state between workers without job restarts.

Experimental Evaluation

We evaluated the DR module using synthetic Zipfian datasets and real-world workloads, including LastFM music tags and web crawl data. The system was tested against standard hashing and other state-of-the-art rebalancing algorithms like Scan and Readj.

Load Balancing and Scalability

A critical advantage of KIP is its stability as the system scales. As the number of partitions increases, standard hash partitioning becomes increasingly imbalanced. In contrast, KIP maintains a nearly optimal load balance by isolating heavy hitters.

Comparison of load imbalance across different partitioning methods. KIP remains stable and near-optimal even as the number of partitions grows.

Performance Gains

Our results demonstrate significant performance improvements across various tasks:

  • Speedups: We achieved 1.5x to 2x speedups on Zipfian data and up to a 6x speedup on real-world web-crawl and Named Entity Recognition (NER) tasks.
  • Efficiency: KIP maintains lower load imbalance than competitors while keeping state migration costs significantly lower than the Readj method, ensuring the "cure" of rebalancing does not become more expensive than the original skew.

Conclusion

The DR module provides a universal, pluggable API for repartitioning in both synchronous micro-batch (Spark) and asynchronous continuous (Flink) engines. While highly effective, future work is needed to address "extreme skew," where a single key's volume exceeds the capacity of an entire worker node, potentially requiring key fission techniques.

Summary updated

BibTeX
@misc{zvara2021system,
  author = {Zoltán Zvara and Péter G. N. Szabó and Balázs Barnabás Lóránt and András A. Benczúr},
  title = {{System-aware dynamic partitioning for batch and streaming workloads}},
  year = {2021},
  eprint = {2105.15023},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2105.15023},
}
Figure