Skip to content

PATTERN Cited by 1 source

Pull-based compaction scheduling

Context

In Redpanda's shared-nothing architecture, partitions are pinned to specific cores. This means two heavily-compactible partitions may land on the same shard. A naive push-based scheduler would cause those shards to starve, filling disks while other shards idle.

Solution

Cloud Topics decouples compaction scheduling from partition placement via a pull-based model:

  1. A compaction scheduler (running on shard 0 of each compaction node) maintains a priority queue of partitions eligible for compaction.
  2. The priority heuristic is based on Kafka-native concepts:
  3. Dirty ratio โ€” bytes dirty / bytes total vs min.cleanable.dirty.ratio
  4. Time elapsed โ€” time since data became eligible vs max.compaction.lag.ms
  5. Compaction workers run on every shard of every compaction node.
  6. Each worker polls the scheduler for the next-highest-priority partition, executes the compaction pipeline, and uploads results.

Because compaction operates on object storage data + metastore metadata (not local replica state), any shard on any node can compact any partition โ€” work distributes freely across the cluster regardless of leadership or replica placement.

Consequences

  • Eliminates compaction starvation from co-located hot partitions
  • Decouples compaction CPU budget from produce/consume path
  • Enables horizontal scaling of compaction throughput by adding nodes
  • Any broker (not just partition leaders) can contribute compaction capacity

Seen in

Last updated ยท 567 distilled / 1,685 read