---
title: "Kafka producer partitioners: keyed, round-robin and sticky"
description: "On a 4-partition Kafka topic: keyed records share a partition by hash, round-robin spreads keyless ones evenly, and sticky fills one partition per batch."
url: https://monedula.dev/kafka-simulator/scenarios/producer-partitioners/
---

# Kafka producer partitioners: keyed, round-robin and sticky

Scenario 01.2.2 · Producer partitioners. 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 it: https://monedula.dev/kafka-simulator/playground/?scenario=01.2.2

## 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](https://monedula.dev/kafka-simulator/playground/?scenario=01.2.2&t=0)
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](https://monedula.dev/kafka-simulator/playground/?scenario=01.2.2&t=1)
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](https://monedula.dev/kafka-simulator/playground/?scenario=01.2.2&t=2)
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](https://monedula.dev/kafka-simulator/playground/?scenario=01.2.2&t=3)

## 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

- [`batch.size`](https://kafka.apache.org/43/configuration/producer-configs/#producerconfigs_batch.size): The most bytes the producer puts in one batch for a partition (default 16384); a batch goes out when it is full or when linger.ms runs out, whichever comes first. [How batch.size works](https://monedula.dev/kafka-simulator/configs/batch-size/)

## Further reading

- [Apache Kafka documentation](https://kafka.apache.org/43/configuration/producer-configs/#producerconfigs_partitioner.class)
