▶ Interactive Lab

Kafka Partition Routing

Watch how messages with different keys map to partitions.

Advertisement
Same key → same partition. Per-key ordering preserved. Null key → round-robin.

What you're seeing

Kafka partition = unit of parallelism + ordering. Producer hash(key) % numPartitions → which partition receives the message. Same key always same partition. Null key → round-robin (or sticky-batched in newer clients).

Changing partition count breaks the hash mapping. Plan partitions for peak parallelism and don't change frequently. Consumer count ≤ partition count.

★ KEY TAKEAWAY
Kafka key → hash(key) % partitions. Same key always lands on the same partition. Null key → round-robin.
▶ WHAT TO TRY
  • Send the same key multiple times — always one partition.
  • Click Burst 20 — distribution depends on key cardinality.