Kafka Interview Questions: Practice Real Technical Interview Quiz

Reviewed by Mark Dickie · Last updated

Apache Kafka is a distributed event streaming platform that publishes, subscribes to, stores, and processes streams of records at high throughput. For an interview, you should know how producers and consumers interact through topics and partitions. Consumer groups are central; they distribute partition load and track committed offsets, so be ready to explain rebalancing and assignment strategies. Replication with in-sync replicas is the other pillar: it keeps data durable when a broker fails, and min.insync.replicas controls whether producers can still write. You should also be able to contrast at-least-once, at-most-once, and exactly-once delivery, and describe the shift from ZooKeeper to KRaft mode for cluster metadata.

What topics does a Kafka interview cover?

AreaKey concepts to study
ArchitectureBrokers, topics, partitions, offsets, log segments
Producersacks setting, linger.ms, batch.size, compression, idempotence
ConsumersConsumer groups, partition assignment, offset commits, poll loop
ReplicationLeader/follower, ISR, min.insync.replicas, unclean leader election
Delivery semanticsAt-least-once, at-most-once, exactly-once (transactions, EOS)
Cluster coordinationZooKeeper vs KRaft, controller, metadata quorum

How should I prepare for Kafka interview questions?

  1. Study the producer and consumer configuration knobs that affect throughput and durability: acks, linger.ms, batch.size, compression.type, enable.idempotence. Know which ones trade latency for throughput and which trade availability for durability.
  2. Draw out a multi-partition topic with a consumer group so you can explain partition rebalancing, assignment strategies (range, round-robin, sticky, cooperative), and how offset commit choices affect correctness.
  3. Work through a failure scenario: a broker goes down, a leader partition migrates, ISR shrinks. Explain what happens to producers and consumers, and what min.insync.replicas controls in that moment.
  4. Be able to contrast at-least-once with exactly-once processing, and describe how Kafka transactions and the transactional producer/consumer API make EOS possible. Know the cost: transactions add overhead and require a transaction coordinator.

Key facts

  • Tarmac has 100 Apache Kafka interview questions on this topic, 10 of them on this page, at difficulty 1–5 of 5.
  • Tarmac last reviewed these Apache Kafka interview questions on 10 August 2026.

At a glance

Questions10 shown · 100 in the bank
Difficulty1–5 of 5
FormatsMultiple choice, Code output, True / false, Flashcard, Multiple answer, Short answer, Ordering, Fill in the blank, Find the bug, Design exercise

What you'll review

  1. brokers topics
  2. consumer lag
  3. partition keys
  4. exactly once
  5. consumer groups
  6. producer batching

Practice questions

Apache Kafka/architecture/brokers-topics

What is a Kafka "topic"?#

Options

Show answer

A Kafka topic is a named, ordered, append-only stream of records that producers publish to and consumers read from. It is physically split into one or more partitions — each its own independently ordered log — which is what lets Kafka parallelize both writes and reads across a topic instead of serializing everything through one log.

Why:

A topic is the named category producers publish to and consumers subscribe to. It isn't one physical log — it's split into one or more partitions (each an independently ordered, append-only log), which is how Kafka gets both parallelism (different partitions can be produced to and consumed from independently) and horizontal scale across brokers. Records within a topic aren't updated in place; a topic is append-only, and old records age out per the topic's retention policy rather than being edited.

Apache Kafka/client-operations/consumer-lag

In Kafka, a consumer tracks its progress with a committed offset for each partition, while the broker reports the log-end-offset (LEO) — the offset of the next message to be appended. Consumer lag for a partition is defined as LEO minus the committed offset. The Python snippet below stores LEO values in end_offsets and committed offsets in committed for three partitions (0, 1, and 2), then computes total lag. What does it print?#

end_offsets = {0: 1000, 1: 2000, 2: 1500}
committed   = {0:  800, 1: 1800, 2: 1500}

total_lag = sum(end_offsets[p] - committed[p] for p in end_offsets)
print(total_lag)
Show answer
400
Why:

Consumer lag per partition = LEO − committed offset. Partition 0: 1000 − 800 = 200; partition 1: 2000 − 1800 = 200; partition 2: 1500 − 1500 = 0. Summing gives 200 + 200 + 0 = 400. A lag of 0 on partition 2 means the consumer is fully caught up on that partition.

Apache Kafka/partitions-consumers/partition-keys

Kafka guarantees message ordering across an entire topic, not just within a single partition.#

Options

Show answer

False. Kafka only guarantees ordering within a single partition — messages within one partition are read back in exactly the order written, but there is no ordering guarantee across a topic's different partitions. Anything needing per-entity ordering must key its messages so all of that entity's records land on the same partition.

Why:

False. Ordering is only guaranteed within a single partition — messages written to partition 0 are read back in exactly the order they were written, but there is no ordering guarantee across partitions 0, 1, and 2 of the same topic; a consumer reading multiple partitions can see them interleaved in any order. This is why anything that needs per-entity ordering (e.g. all events for one user in order) has to key its messages so all of that entity's records land on the same partition — see the related partition-key question.

Apache Kafka/architecture/brokers-topics

What is a "partition" in Kafka?#

Show answer

One independently-ordered, append-only log that a topic is split into. Every record within a single partition has a strictly increasing offset and is read back in the exact order it was written; there is no ordering guarantee across different partitions of the same topic. Partitions are the unit of parallelism (different partitions can be produced to and consumed from independently) and of replication (each partition is copied across a set of brokers).

Why:

A topic is a logical stream; a partition is the physical, ordered log it's actually split into — the distinction is what makes both ordering (per-partition) and scale (across partitions) possible at once.

Apache Kafka/delivery-guarantees/exactly-once

Which of these are genuine, configurable Kafka delivery-guarantee levels? Select all that apply.#

Options

Pick every one that applies.

Show answer

Kafka supports three real delivery semantics: at-most-once, at-least-once and exactly-once. Each is a different tradeoff of commit timing and producer configuration. At-most-once commits offsets before processing, so a crash between the two loses the message but never reprocesses it. At-least-once commits after processing, so a crash between the two reprocesses the message but never loses it — this is the default behaviour and the reason consumer logic needs to be idempotent. Exactly-once layers an idempotent, transactional producer and read_committed consumers on top to get neither loss nor duplicates. "Best-effort-once" and "eventual-once" are not Kafka terminology.

Why:

At-most-once, at-least-once, and exactly-once are the three real delivery semantics Kafka supports, each a different tradeoff of commit timing and producer configuration: at-most-once commits offsets before processing (crash between the two loses the message but never reprocesses), at-least-once commits after processing (crash between the two reprocesses but never loses), and exactly-once layers an idempotent, transactional producer with read_committed consumers on top to get both no loss and no duplicate. 'Best-effort-once' and 'eventual-once' aren't real Kafka terminology — they're plausible-sounding names invented to test whether you actually know the three real ones.

Apache Kafka/partitions-consumers/consumer-groups

What is a Kafka consumer group, and how does partition assignment work within one?#

Show answer

A consumer group is a set of consumer instances that share a group.id and cooperatively consume a topic, splitting its partitions between them so each partition is owned by exactly one consumer in the group at a time — this is how Kafka gets parallel consumption of one topic across multiple processes/machines while still processing each partition's messages in order. The group coordinator (a broker) tracks membership and triggers a rebalance whenever a consumer joins, leaves, or is considered dead (missed heartbeats) — at which point partitions are redistributed among the remaining/new members. Different consumer groups are fully independent: each group gets its own copy of every message on the topic, tracked by its own offsets, which is how one topic can feed multiple unrelated downstream applications.

Why:

The two things to get right: within a group, partitions are divided so each is owned by exactly one member, giving parallelism without breaking per-partition ordering; and across groups, membership is independent, so multiple groups reading the same topic each get the full stream. Rebalancing — redistributing partitions when membership changes — is the mechanic that makes this work dynamically as consumers scale up, scale down, or fail.

Apache Kafka/architecture/brokers-topics

Order the path a message takes from being sent by a producer to being processed by a consumer.#

Put these in order

Show answer

A Kafka message's path is: the producer sends it (optionally keyed), the partitioner assigns it to a partition, the partition leader appends it to its log, followers replicate it into the in-sync replica set, the broker acknowledges per the acks setting, and only then does a subscribed consumer poll, read, and commit its offset for that record. With acks=all, the acknowledgment is deliberately held until replication completes, which is what makes it mean the write is durable rather than merely written somewhere.

Why:

This is the full round trip: the producer hands off a record, the partitioner deterministically routes it to a partition based on its key (so same-key records land together, preserving order for that key), the leader for that partition appends it to its log, followers replicate it to build durability, the broker acknowledges per the acks config (none/leader-only/full-ISR), and only then does a subscribed consumer poll and read it — finally committing its offset to record that it's been consumed. Getting the order of replicate-then-ack right matters: with acks=all, the ack is deliberately held until the ISR has replicated, which is what makes the acknowledgment mean 'durable', not just 'written somewhere'.

Apache Kafka/client-operations/producer-batching

A Kafka producer accumulates records into a batch per partition. It sends that batch immediately once it reaches _____ bytes; if the batch is still not full, the producer waits up to _____ milliseconds for more records before sending it anyway.#

Show answer

A Kafka producer accumulates records into a batch per partition. It sends that batch immediately once it reaches batch.size bytes; if the batch is still not full, the producer waits up to linger.ms milliseconds for more records before sending it anyway.

Why:

These two settings are the whole of producer batching, and they work as a race: whichever limit is hit first triggers the send. batch.size (16384 bytes by default) is an upper bound held per partition, not per request — a single request to a broker carries one batch for each partition it has data for. linger.ms is the deliberate wait the producer adds before sending a partly-filled batch, which is why raising it trades a little latency for larger batches, better compression ratios and fewer requests. Two details that catch people out: setting batch.size to 0 disables batching entirely rather than making it unlimited, and linger.ms changed its default from 0 to 5 in Kafka 4.0, so most tutorials and older interview guides still quote a default that no longer holds. Compression is applied per batch, which is why the two settings are the lever for throughput and compression ratio at the same time.

Apache Kafka/partitions-consumers/partition-keys

This producer publishes per-user account events, and downstream consumers assume they can process one user's events strictly in the order they happened. In production, some users' events are occasionally processed out of order. Which line causes it?#

1| async function publishAccountEvent(event) {
2|   await producer.send({
3|     topic: 'account-events',
4|     messages: [
5|       { key: null, value: JSON.stringify(event) },
6|     ],
7|   });
8| }

Options

Show answer

Line 5 — key: null gives the partitioner nothing to route on, so it spreads messages across all partitions instead of pinning a user to one, and a given user's events land on different partitions with no ordering guarantee between them

Why:

Kafka only orders messages within a single partition, so per-user ordering requires every event for the same user to consistently land on the same partition. With key: null the partitioner has no key to hash, so it distributes records on a basis that has nothing to do with which user an event belongs to — per-record round-robin in KafkaJS (the client shown here), and sticky batching, a batch at a time, in the Java client since Kafka 2.4 — so two events for the same user can easily end up on different partitions, and there's no guarantee about the relative order in which a consumer reading multiple partitions sees them. The fix is keying each message by event.userId (key: event.userId): the partitioner hashes the key to consistently route every event for that user to the same partition, which is what actually delivers the strict per-user order the downstream consumers assume.

Apache Kafka/partitions-consumers/partition-keys

Design the Kafka side of an order pipeline. Order events — created, paid, shipped, cancelled — flow in at a peak of 50k events/sec, and three independent consumers read them: a billing service that must never double-charge, a search indexer that tolerates duplicates happily, and a warehouse loader that has to replay the last 30 days whenever its schema changes. About 2% of orders belong to a handful of very large enterprise tenants. Cover topic and partition design, ordering, the delivery guarantee each consumer needs, retention, and what happens when things fail. State your assumptions.#

Show answer

Assume events average 1 KB, ordering matters per order and not across orders, and the business will pay for 35 days of retention to give the 30-day replay some headroom.

One topic, order-events, carrying all four event types, keyed by order id. One topic keeps a single order's lifecycle in one partition, which is the only ordering Kafka can actually give me; splitting by event type would scatter one order's created and paid across topics and make ordering impossible to reason about. Order id is deliberately chosen over tenant id: tenant id looks attractive because it would order a tenant's whole history, but with 2% of orders concentrated in a handful of enterprises it would drive those tenants onto one or two partitions and leave the rest idle — a hot partition that no amount of extra consumers can relieve, because one key always maps to one partition.

At 50k/sec and roughly 1 KB per event that is about 50 MB/sec. A partition comfortably handles some tens of MB/sec, but sizing to the theoretical minimum leaves no headroom, and partition count can be raised and never lowered — so I would start around 24 to 32 partitions, measured against a real load test rather than guessed. Over-provisioning is cheap; discovering later that I need more is not, because raising the count re-hashes keys and an order that has already emitted created on the old partition can emit paid on a new one, breaking exactly the guarantee the key existed to provide. If I ever do need to widen, the safe path is a new topic at the new count with consumers cut over once the old one has drained.

Three consumer groups, three different guarantees. Search runs at-least-once and does nothing special: reindexing the same document twice is a no-op, so it commits after processing and moves on. Billing is the hard one, and the key point is that Kafka's exactly-once is Kafka-to-Kafka — it cannot make an external payment provider charge once. So billing derives an idempotency key from the order id and the payment attempt, sends it with the charge, and lets the provider collapse duplicates; Kafka then only needs at-least-once, which it already gives me. If billing also writes a result back into Kafka, I would wrap the read, the charge record and the offset commit in a transaction with read_committed downstream, so no partial state is visible. The warehouse loader batches and is idempotent by upsert on order id.

Retention is 35 days, so the 30-day replay is always inside the window; at this volume that is a real storage bill, which is where tiered storage earns its place by pushing older segments to object storage. Replay itself is just an offset reset on the warehouse group, or a brand-new group id starting from earliest. Consumer groups have completely independent offsets, so this does not touch billing or search — and that independence is the answer to the replay question: billing never sees the replayed events because it is a different group with its own committed position.

Durability is replication factor 3, acks=all, min.insync.replicas=2, so a write survives one broker loss and is rejected rather than silently single-copied if the ISR shrinks further. On failures: a record that cannot be processed goes to order-events-dlq with the exception attached after a bounded number of retries, never dropped and never retried forever — an infinite retry on one poison record stalls the whole partition behind it. When billing is down its lag simply grows while search and the warehouse carry on unaffected, and on restart it resumes from its last committed offset and works through the backlog; the only thing I must watch is that the outage stays well inside retention. Monitoring is lag per partition, not just the average, because the enterprise tenants mean a single partition can be badly behind while the mean looks healthy — max lag against average lag is the cheapest hot-partition detector there is. Slow processing gets max.poll.records lowered rather than max.poll.interval.ms raised, so a backlog does not turn into a rebalance loop.

The main tradeoff is transactions against downstream idempotency. Transactions give a clean story inside Kafka but add coordinator overhead, hold the Last Stable Offset back for read_committed readers, and still do not cover the payment provider. Idempotency keys are less elegant and put the burden on the consumer, but they work across the system boundary that actually matters here. I would take the idempotency key.

Why:

This exercise sorts people who have operated Kafka from people who have configured it once. Four tells recur. A weak answer creates a topic per event type or per consumer, which destroys per-order ordering and multiplies the operational surface for no gain. It keys on tenant id, which reads as sensible until you notice that 2% of orders sit in a handful of tenants and one partition is now carrying most of the traffic — and adding partitions cannot fix it, because a single key still hashes to a single partition. It answers 'never double-charge' with 'enable exactly-once', missing that Kafka's transactional guarantee stops at Kafka's boundary and that charging an external provider once requires idempotency at that provider. And it treats replay as dangerous, when independent consumer-group offsets are exactly what makes replaying 30 days into the warehouse invisible to billing. The partition-count probe is the sharpest discriminator: the count can be raised and never lowered, and raising it re-hashes keys so an in-flight order's events split across two partitions — which is why the right move is over-provisioning up front and, if you truly must widen, cutting over to a new topic.

Related interview questions

The other 90 questions

This page shows 10. A free account opens the rest and marks your answers, which a page of answers can't do. Miss one and it returns a few days later, then a week after that, until you stop missing it.

Start free

Free · the whole bank · 100 graded answers per 30 days · written feedback and job-ad quizzes on the paid plan

What moved, monthly

One email a month when the bulletin comes out: what moved in the markets we track, and the new question topics we published. Confirm your address to join. Unsubscribe any time.