Kafka reference

Keys and partitions

Routing

Record hasDefault producer doesOrder you can rely on
A keytoPositive(murmur2(keyBytes)) % numPartitionsPer key, while the partition count is unchanged
No keySticks to one partition for about batch.size bytes, then movesPer partition only, nothing per key
An explicit partitionUses that partitionPer partition

Producer settings

ConfigDefaultEffect
partitioner.classnullNull uses the built-in logic. Can be RoundRobinPartitioner or your own Partitioner.
partitioner.ignore.keysfalseIf true, keys are not used to choose a partition.
partitioner.adaptive.partitioning.enabletrueSends more to partitions on faster brokers.

Rules worth memorising

Commands

kafka-topics.sh --bootstrap-server HOST:9092 --create --topic T --partitions 3 --replication-factor 1
kafka-topics.sh --bootstrap-server HOST:9092 --describe --topic T
kafka-topics.sh --bootstrap-server HOST:9092 --alter --topic T --partitions 6

Related ideas