How are Kafka topics partitioned, and why does it matter?

Kafka topics are partitioned by splitting each topic's log into multiple independent, ordered segments that can be distributed across different brokers and processed in parallel.

Key Points

Example

A topic with 12 partitions spread across 4 brokers lets up to 12 consumers in the same group each process a dedicated slice of the traffic simultaneously, which would be impossible if the topic were a single unpartitioned log.

# 12 partitions = up to 12 consumers in one group working in parallel
kafka-topics.sh --bootstrap-server localhost:9092 \
  --create --topic events --partitions 12 --replication-factor 3

// Java: the key decides the partition (hash of key % number of partitions),
// so every event for customer C-42 lands on the same partition, in order.
kafkaTemplate.send("events", "C-42", "LOGIN");
kafkaTemplate.send("events", "C-42", "ADD_TO_CART");
kafkaTemplate.send("events", "C-42", "CHECKOUT");

// Without a key, records are spread across partitions (sticky partitioner),
// which balances load but gives no ordering between them.
kafkaTemplate.send("events", "PAGE_VIEW");

Interview Tip

A concise interview answer is

Topics are partitioned by splitting their log into multiple ordered segments distributed across brokers, which is important because it's what allows Kafka to scale throughput horizontally and lets multiple consumers in a group process the topic in parallel, at the cost of only guaranteeing order within each partition.

Last updated: 11 November 2026

Previous question: How do you create a topic in Kafka?

Next question: What happens when a topic is replicated in Kafka?

More Kafka (Optional) interview questions

All Kafka (Optional) questions