Explain Kafka topics, partitions, and offsets.
A Kafka topic is a named, durable, append-only log that producers write to and consumers read from. Topics are the primary organizational unit — you create a topic for each logical stream of data (e.g., `user-events`, `order-updates`).
A topic is divided into one or more partitions. Each partition is an independent, ordered, immutable log stored on a broker's disk. Partitions are the unit of parallelism in Kafka: multiple consumers in a consumer group can read different partitions concurrently, and multiple brokers can host different partitions of the same topic, enabling horizontal scaling. The partition count also sets the maximum parallelism ceiling for any consumer group reading that topic.
Messages within a partition are assigned a monotonically increasing integer called an offset. Offsets are per-partition and always increase — Kafka never reuses or modifies them. The offset is the consumer's cursor into a partition: by committing an offset, a consumer records that it has processed all messages up to that point. On restart, it resumes from the committed offset.
Ordering in Kafka is guaranteed within a partition, not across partitions. If you need all events for a specific entity (e.g., all orders for customer_id=42) to be processed in order, you must route them to the same partition by using a consistent partition key. By default, the producer hashes the message key to select a partition — messages with the same key always go to the same partition.
Messages are retained in Kafka for a configurable period (or until a size limit is hit) regardless of whether they've been consumed. This means consumers can re-read historical data by seeking to an earlier offset, and multiple consumer groups can independently consume the same topic at different paces without affecting each other.
Correctly defines topic, partition, and offset with their relationships. Understands that offsets are per-partition and monotonically increasing. Knows that ordering is within a partition only.
Explains how partition keys enable ordered delivery for related events, connects partition count to consumer group parallelism ceiling, and understands that Kafka retention allows re-reading and independent multi-group consumption.
Reading the answer is step one. Explaining it unprompted — under interview pressure — is what actually matters. Get AI-graded feedback on your answer with follow-up probes on your weak points.
Get Graded — Free Assessment