VWhen is Kafka a better fit than a simple message queue?
Interviewer questionKafka
Kafka interviews usually start with why it exists and how it differs from a classic message queue, then go into partitions, consumer groups and delivery guarantees. Many questions are really about what happens when something fails.
Explain with a small example: a topic called orders, three partitions and two consumers. A concrete picture helps both you and the interviewer, and it stops you from using vague words.
- ✓Words → phrases → sentences → speaking
- ✓Answer meaning
- ✓Language
Common questions and sample answers
When is Kafka a better fit than a simple message queue?
What the interviewer wants to hear. The idea of a log with replay, multiple consumer groups and throughput, and an honest limit.
Sample answer to practise aloudKafka is a distributed, append-only log. Messages are not removed when they are read. They stay for a configured time, and each consumer group keeps its own position, called an offset. This is useful when several systems need the same events, when I want to replay history, for example after a bug fix, or when throughput is very high. A simple queue like RabbitMQ is often better for task distribution with complex routing, where each message is processed once and then disappears. If the load is small and I do not need replay, a simple queue is easier to run.
How do partitions affect ordering and scaling?
What the interviewer wants to hear. Ordering only inside a partition, keys, and partitions as the unit of parallelism.
Sample answer to practise aloudA topic is split into partitions, and each partition is an ordered log. Kafka guarantees ordering only inside one partition, not across the whole topic. The producer chooses the partition, usually by hashing the message key, so all messages with the same key, for example one customer ID, go to the same partition and stay in order. Partitions are also the unit of parallelism: more partitions allow more consumers to work in parallel. But the number cannot be reduced later, and increasing it changes where new messages with the same key go, so I choose it with growth in mind.
What is a consumer group, and what happens when a consumer fails?
What the interviewer wants to hear. Partition assignment, rebalancing and committed offsets.
Sample answer to practise aloudA consumer group is a set of consumers that share the work of a topic. Each partition is assigned to only one consumer in the group, so the group processes the topic in parallel without duplicates. If there are more consumers than partitions, the extra ones stay idle. When a consumer crashes or a new one joins, Kafka rebalances: it reassigns partitions between the members. The new owner continues from the last committed offset. During a rebalance, processing pauses for a moment, so I try to keep processing fast and to avoid long pauses that look like a failure.
What delivery guarantees does Kafka give?
What the interviewer wants to hear. At most once, at least once and exactly once, with the conditions for each.
Sample answer to practise aloudIn practice there are three levels. At most once means that a message can be lost but is never repeated. At least once means that it is never lost but can be repeated, and this is the most common setup: I commit the offset only after processing. Exactly once is possible with the idempotent producer and transactions, mainly for flows from Kafka to Kafka. For a producer, I set acks to all and use enough in-sync replicas, so a broker failure does not lose data. Because duplicates can still happen, I make my consumers idempotent.
What is consumer lag, and what do you do when it grows?
What the interviewer wants to hear. A clear definition, a diagnosis step and several possible fixes.
Sample answer to practise aloudConsumer lag is the difference between the latest offset in a partition and the offset the consumer has processed. If it grows, the consumers cannot keep up. First I look at why: is processing slow because of a database call, or did the producer traffic increase? Then I have a few options. I can optimise the processing, add consumers up to the number of partitions, or add partitions if I need more parallelism. I set an alert on lag, because a growing lag is usually the first signal of a problem, long before users complain.
How to say the key terms
- Kafka
- KAF-kuh
- partition
- par-TISH-un
- offset
- OFF-set
- broker
- BROH-ker
- throughput
- THROO-poot
- replica
- REP-lih-kuh
Useful phrases for answering
- Think of a topic as an append-only log.
- Ordering is guaranteed only within a partition.
- We commit the offset after processing.
- The consumer has to be idempotent, because duplicates can happen.
- It depends on the required guarantees and the throughput.
- In that case I would look at the consumer lag first.
Common mistakes to avoid
- Saying Kafka guarantees global ordering. It guarantees order only inside a partition.
- Saying "exactly once" without the conditions. Mention idempotent producers and transactions, and that consumers should still be idempotent.
- Treating Kafka as a database for everything. It is excellent for event streams, so say what you store elsewhere.
- Never mentioning failure. Explain what happens when a broker or a consumer goes down.
Frequently asked questions
Do I need to know Kafka internals for a normal backend interview?
You need the model: topics, partitions, offsets, consumer groups and delivery guarantees. Internals such as the controller or log segments are for specialist roles.
Which tools or versions should I mention?
Say what you used: the client library, how you monitored lag, and whether you used a schema registry. Honest details matter more than version numbers.
How can I practise explaining Kafka without notes?
Draw one small example of a topic with three partitions and say what happens when a message arrives, when a consumer fails and when you add a consumer. Repeat it aloud until it takes about a minute.
Reading an answer is not the same as saying it. Practise each question out loud, then compare the meaning and the language of your own answer.
Try SpeakRole ↗Other topics in this area