Kafka Interview Questions and Answers
Kafka interviews start with the model (topics, partitions, offsets, consumer groups) and quickly move to guarantees and failure: what happens when a consumer is slower than the producer, how ordering works across partitions, what exactly-once really means, and how replication and leader election keep data safe.
The questions below run from basics to production scenarios such as lag, rebalances, retries and backpressure. Learn the trade-offs, not only the definitions: they are what senior interviewers ask about.
Questions
- Why is Kafka required? What problem does it solve?
- What is the difference between Synchronous and Asynchronous processing in system design?
- What are the ways to do asynchronous processing in system design?
- What is a Message Queue?
- What is Event Streaming?
- What is the difference between a Message Queue and Event Streaming?
- Is Kafka a Message Queue or an Event Stream?
- What is Kafka?
- What is a Topic in Kafka?
- Is a Topic the same as an Event?
- What are Partitions and Brokers in Kafka?
- How is ordering guaranteed within a partition?
- What is a Consumer Group and how does rebalancing work?
- What is the difference between a Topic and a Partition?
- How do you add a topic in Kafka and choose its configuration?
- What is an Offset and how do multiple consumers use it?
- Where are offsets stored and who stores them?
- How do consumers actually consume events from Kafka (pull vs push)?
- What is a Broker and what does it store?
- What is Partition Replication in Kafka?
- What are Leader and Follower brokers?
- What is Kafka metadata and how is the cluster coordinated?
- Walk through the complete end-to-end Kafka flow.
- Why is ordering guaranteed within a partition but not across partitions?
- Can multiple consumers read from the same partition?
- How many partitions should you choose when defining a topic?
- When are events deleted from Kafka?
- What are offset commit strategies and the delivery guarantees (at-most-once, at-least-once, exactly-once)?
- Exercise — Delivery Guarantees: make an at-least-once consumer idempotent.
- How do consumers know an event has arrived, and how does Kafka handle a consumer crash?
- Does every event have an offset, and who assigns it?
- What is Backpressure and how does Kafka handle it?
- What does Kafka do when a topic is created?
- How do you add a consumer group to an existing topic?
- How does Kafka handle a huge number of write operations?
- What is the Pub-Sub model and how does Kafka relate to it?
- Why is Kafka not "just" Pub-Sub?
- When should you use Kafka and when a simpler Pub/Sub (or queue)?
- Kafka vs RabbitMQ — what are the key differences?
- Can a partition contain events of multiple topics?
- Do you create new partitions for every new topic?
- Can a consumer consume from multiple topics?
- How do large systems like Uber, Amazon, YouTube, and WhatsApp use Kafka?
- When should you (and shouldn't you) use Kafka in a system design interview?
- Exercise — Kafka Design: build an order-processing pipeline with ordering and no data loss.
- What is KafkaProducer and is it thread-safe?
- Is `send()` synchronous or asynchronous, and how do you wait for the result?
- Explain the `acks` setting (0, 1, all) and which is strongest.
- What is `min.insync.replicas` and what happens if the ISR falls below it?
- Explain producer batching: `batch.size` and `linger.ms`.
- What is producer compression and what are the trade-offs?
- What is the idempotent producer and why is it important?
- What is `max.in.flight.requests.per.connection` and how does it affect ordering?
- Explain the producer timeout/retry settings: `delivery.timeout.ms`, `retries`, `retry.backoff.ms`, `max.block.ms`.
- What is `buffer.memory` and what happens when the buffer fills?
- How does the partitioner decide which partition a record goes to?
- How does changing the partition count affect keyed records?
- What is a producer interceptor and when would you use one?
- How do you serialize keys and values, and how does Avro/Schema Registry fit in?
- How do you improve producer throughput vs latency?
Related
Frequently asked questions
What is a consumer group in Kafka?
A set of consumers that share a topic's partitions, so each partition is read by exactly one consumer in the group. It is how Kafka scales consumption while keeping per-partition ordering.
Does Kafka guarantee ordering?
Only within a partition. If you need ordering for related events, give them the same key so they go to the same partition.
What does exactly-once mean in Kafka?
With idempotent producers and transactions, a message is written once and a consume-process-produce chain can commit atomically. It does not make external side effects exactly-once by itself.