Monedula

Scenario 01.2.2 · Producer partitioners

Kafka producer partitioners: keyed, round-robin and sticky

Producers & EOS · Intermediate · about 3 min · Apache Kafka 4.3

Keyed records co-partition by hash; keyless records spread (round-robin) or cluster per batch (uniform-sticky).

Run this scenario in the playground

Uniform-sticky: one partition per batch. t+2.400s

No-key records stick to a single partition, then the sticky partition moves on for the next batch. In Kafka 4.x this is the default partitioner's keyless mode (KIP-794), which switches only after batch.size bytes, to a random load-weighted partition; the simulator switches per batch to make it visible.

Open at this step: step 4, Uniform-sticky: one partition per batch

What you start with

The partitioner decides which partition each record lands on. Across three phases on a 4-partition topic you see all three behaviors: keyed records hash to a partition (the two K1 writes co-partition), round-robin spreads keyless records one-per-partition, and uniform-sticky (in Kafka 4.x, the default partitioner's keyless behaviour) packs records onto one partition before switching.

Step by step

  1. Idle t+0.000s One producer, a 4-partition topic. Default partitioner. Open at this step: step 1, Idle
  2. Keyed: same key, same partition t+0.700s Default partitioner, keyed records. K1 was produced twice and both copies hashed to the same partition (co-partitioning ⇒ per-key ordering). Open at this step: step 2, Keyed: same key, same partition
  3. Round-robin: even spread t+1.400s No-key records cycle across all four partitions, one step per record - an even load spread. Open at this step: step 3, Round-robin: even spread
  4. Uniform-sticky: one partition per batch t+2.400s No-key records stick to a single partition, then the sticky partition moves on for the next batch. In Kafka 4.x this is the default partitioner's keyless mode (KIP-794), which switches only after batch.size bytes, to a random load-weighted partition; the simulator switches per batch to make it visible. Open at this step: step 4, Uniform-sticky: one partition per batch

The takeaway

A record's partition comes from its key (same key → same partition, preserving per-key order) or, when keyless, from the partitioner strategy - round-robin for even spread, sticky for fewer, fuller batches.

Configs in this scenario

Embed this scenario

Paste this into a blog post, a course page or your team's docs. The scenario plays inside your page, and the link under it points readers to this walkthrough.

<iframe src="https://monedula.dev/kafka-simulator/embed/?scenario=01.2.2" title="Kafka Simulator: Producer partitioners" width="100%" height="520" style="border:1px solid #d0d0d0;border-radius:8px" loading="lazy"></iframe>
<p><a href="https://monedula.dev/kafka-simulator/scenarios/producer-partitioners/">Kafka producer partitioners: keyed, round-robin and sticky</a></p>

Further reading

Apache Kafka documentation

More in Producers & EOS

All scenarios