liveBook · Manning

Round-robin load balancing

As explained in Kafka for Architects

A round-robin approach assigns successive items cyclically across available destinations to distribute work evenly.

Round-robin load balancing distributes producer messages across available Kafka partitions in a repeating cycle. It ignores message keys, sends records one by one, and returns to the first partition after reaching the last. The result is an approximately even data distribution when message ordering is not the primary requirement. section 3.2.1 section 3.2.6

Use the strategy when the architectural priority is balanced distribution rather than key-based sequencing:

  • Choose round-robin when message order is not important and processing parallelism or balanced partition load matters. section 3.2.6
  • Do not rely on it for per-key ordering or co-location, because keys are ignored and related records may reach different partitions. section 3.2.1
  • Prefer key-based partitioning when messages sharing a key must remain in sequence on one partition. section 3.2.1 section 3.2.6

Cyclical assignment

With three available partitions, successive records follow a repeating pattern such as partition 0, partition 1, partition 2, partition 0, and so on. Each partition therefore receives approximately the same amount of data, provided the available partitions remain unchanged. section 3.2.1

partition.class=org.apache.kafka.clients.producer.RoundRobinPartitioner

Inspect the producer partitioner configuration for the RoundRobinPartitioner class. section 3.2.1

How Kafka for Architects covers it

How deep it goes
Defines cyclical assignment and its ordering trade-off, but stops short of a low-level implementation walkthrough.
Examples
Uses cyclical assignment across partitions and identifies the RoundRobinPartitioner configuration class.
What it assumes
Assumes familiarity with Kafka producers and partitions while defining the ordering and load-distribution trade-off.
What you can do after
Apply it via Kafka producer partitioner configuration when even distribution outweighs per-key ordering.
How it connects
Connects Kafka partitions, producer applications, message ordering, partitioning strategy, and processing parallelism.

Also explained in

Compare how 3 books explain round-robin load balancing →

Related concepts

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