Practice 45 Kafka interview questions on topics, partitions, brokers, producers, consumers, consumer groups, offsets, retention, compaction, and delivery guarantees.
45 questions with answersKey Takeaways
Apache Kafka is a distributed event streaming platform for durable event logs, real-time pipelines, and asynchronous system communication. Producers write records to topic partitions, brokers store replicated logs, and consumers read records by offset. In interviews, Kafka questions test whether you understand ordering, replay, consumer groups, partitioning, retention, compaction, and operational failure modes.
Watch: Introduction to Apache Kafka Fundamentals
Video: Introduction to Apache Kafka Fundamentals (Confluent, YouTube)
Test yourself and earn a certificate
6 quick questions. Score 70%+ to download your Kafka certificate.
Start here. These are the definitions and first-principle checks that open most rounds.
A topic is a named stream of records split into partitions.
Producers write to topics and consumers read from them.
Topic changes Kafka decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Watch a deeper explanation
Video: Introduction to Apache Kafka Fundamentals (Confluent, YouTube)
Partitions divide a topic for parallelism, ordered logs, and scalable storage.
Ordering is guaranteed only within one partition.
Partition changes Kafka decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Kafka record path
The key controls partition placement when configured.
A broker is a Kafka server that stores partitions and handles producer and consumer requests.
A cluster has multiple brokers for scale and fault tolerance.
Broker changes Kafka decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Replication keeps partition data available if a broker fails.
Each partition has a leader and follower replicas.
Replica changes Kafka decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
| Answer part | What to say | Evidence to mention |
|---|---|---|
| Definition | Replica in one direct sentence. | Official docs or course material |
| Use case | The work where it changes a decision. | Dataset, model, query, dashboard, or pipeline |
| Risk | What breaks when it is misunderstood. | Metric, log, test result, or review note |
The leader handles reads and writes for a partition while followers replicate from it.
Leader election happens when the leader broker fails.
Leader changes Kafka decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Watch a deeper explanation
Video: Kafka tutorial for beginners (Confluent Developer, YouTube)
A producer sends records to Kafka topics and chooses partitions by key, custom logic, or default strategy.
Producer settings affect reliability, latency, and throughput.
Producer changes Kafka decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
A consumer reads records from topic partitions and tracks progress with offsets.
Consumers can replay by seeking to earlier offsets if retention allows it.
Consumer changes Kafka decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
A consumer group lets multiple consumers share partitions from a topic so records are processed in parallel.
Within one group, one partition is consumed by one consumer at a time.
Consumer group changes Kafka decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
An offset is a record's position inside a partition log.
Committed offsets mark how far a consumer group has processed.
Offset changes Kafka decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Retention controls how long records stay in Kafka based on time, size, or policy.
Records can remain after being consumed.
Retention changes Kafka decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Log compaction keeps the latest value for each key while removing older values for that key over time.
It is useful for state topics.
Compaction changes Kafka decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
acks controls how many broker confirmations the producer waits for before considering a write successful.
acks=all gives stronger durability with higher latency.
Acknowledgment changes Kafka decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
An idempotent producer prevents duplicate records caused by producer retries within a session.
It helps make retries safer.
Idempotent producer changes Kafka decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Watch a deeper explanation
Video: The Confluent Platform (Confluent, YouTube)
Consumer lag is the difference between the latest offset and the consumer group's committed or processed offset.
Lag shows how far the consumer is behind.
Consumer lag changes Kafka decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
A dead-letter topic stores records that could not be processed after validation or retry rules.
It keeps bad records visible without blocking the whole stream.
Dead-letter topic changes Kafka decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
These questions test whether you can apply the topic to real data, real code, and messy constraints.
Choose a key that preserves needed ordering and spreads load evenly across partitions.
A user id may work for user-ordering, but a hot user can create skew.
choose partition key changes Kafka decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
# Interview check: split data, run baseline, inspect metric
from sklearn.metrics import accuracy_score
print(accuracy_score(y_true, y_pred))Define event names, key, schema, partition count, retention, compatibility, and consumers.
The key decision is whether the topic represents facts, commands, or state changes.
design event topic changes Kafka decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Make consumers idempotent using event ids, unique keys, processed tables, or safe merge logic.
At-least-once processing can create duplicates.
handle duplicates changes Kafka decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Commit after the record or batch is processed successfully according to the sink's consistency rule.
Committing too early risks data loss after failure.
commit offsets changes Kafka decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Track consumer group lag, processing rate, input rate, rebalance events, and sink latency.
Lag needs context. A short spike may be normal.
measure lag changes Kafka decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Scale consumers up to partition count, improve processing, batch writes, fix slow sinks, or increase partitions if design allows.
More consumers than partitions in one group do not add parallelism.
fix lag changes Kafka decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Use bounded retries, delay topics where fit, idempotent processing, and a dead-letter topic after final failure.
Retry loops should not block good records forever.
retry failed records changes Kafka decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Use a schema registry or contract, compatibility rules, optional additive fields, and versioned consumers.
Breaking changes need coordinated rollout.
schema evolution changes Kafka decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Base it on replay need, storage cost, legal rules, and consumer recovery time.
Short retention can make slow consumers unrecoverable.
topic retention changes Kafka decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Use compaction when consumers need the latest state per key, such as account status or reference data.
Do not use compaction for audit history that needs every event.
compacted topic changes Kafka decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Watch a deeper explanation
Video: Confluent offerings and Kafka 101 (Confluent, YouTube)
Use acks=all, retries, idempotence, sensible timeout settings, and monitoring for errors.
Reliability settings may increase latency.
producer reliability changes Kafka decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Partitions are reassigned among consumers in a group, which can pause processing and change ownership.
Long processing can trigger unnecessary rebalances.
consumer rebalance changes Kafka decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Use the same partition key for that user's events and process them within one partition.
Global ordering across partitions is not guaranteed.
order guarantee changes Kafka decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Use TLS, authentication, ACLs, network controls, audit logging, and secret management.
Security includes brokers, clients, schemas, and operational access.
secure Kafka changes Kafka decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Estimate message size, throughput, retention, replication factor, partitions, consumer rate, and broker disk/network headroom.
Retention and replication multiply storage.
capacity planning changes Kafka decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Advanced rounds test trade-offs, failure modes, and whether the decision can hold up under production pressure.
The partition key is skewed or too many records share the same key.
Change key strategy carefully because ordering may change.
hot partition changes Kafka decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Check lag, errors, rebalances, offsets, dead records, sink latency, and consumer logs.
A poison message can block a naive consumer.
consumer stuck changes Kafka decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Idempotency at the consumer or sink should prevent duplicate business effects.
Kafka delivery settings alone do not replace business idempotency.
duplicate payments changes Kafka decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Check acks, retries, idempotence, producer errors, broker availability, and topic retention.
A producer can lose data if it treats unconfirmed writes as successful.
lost messages changes Kafka decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
A slower code path, sink issue, rebalance loop, bad batch size, or errors may have reduced processing rate.
Compare input and processing rate before and after deploy.
lag after deploy changes Kafka decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Offsets may point to records that no longer exist, so the group cannot replay all missed data.
Recovery may require source replay or backup.
short retention incident changes Kafka decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Compatibility checks, schema registry rules, and producer-consumer contracts.
Removing required fields is usually a breaking change.
schema break changes Kafka decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Check session timeouts, max poll interval, slow processing, consumer crashes, and group membership changes.
Frequent rebalances reduce throughput.
rebalance storm changes Kafka decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Yes. Too many partitions increase metadata, open files, leader election work, and operational overhead.
Partitions are not free.
too many partitions changes Kafka decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Yes, compaction keeps latest values by key over time and can remove older records.
Use normal retention if every event must be preserved.
compaction confusion changes Kafka decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Kafka orders within a partition. Total ordering would require one partition or an external ordering design, which limits scale.
Challenge whether total ordering is truly needed.
cross-partition order changes Kafka decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Replicated partitions can elect new leaders if enough in-sync replicas remain.
Replication factor and min in-sync replicas matter.
broker failure changes Kafka decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Batch writes, tune the database, add backpressure, scale partitions and consumers if possible, or buffer to a more suitable sink.
Kafka can absorb spikes only within retention and capacity.
slow sink changes Kafka decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Consumers may not have enough context unless the event contract defines patch semantics clearly.
State events and fact events need different contracts.
bad event design changes Kafka decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Ask about key choice, ordering, retention, schemas, consumer groups, retries, idempotency, security, lag alerts, and replay plan.
These questions expose real production risk.
senior design review changes Kafka decisions by affecting the chosen method, the failure mode, or the validation step. Reliable evidence comes from a metric, test result, query output, log, or review note.
Kafka is often compared with queues and database tables. The useful answer is about retention, replay, ordering, and consumer ownership.
| System | Data model | Good fit | Interview trap |
|---|---|---|---|
| Kafka | Append-only partitioned log | Event streams, replay, fan-out | Assuming one message disappears after one consumer |
| Queue | Work item queue | Task distribution | Expecting easy replay by many teams |
| Database table | Mutable records | Current state and transactions | Using it as a high-throughput event bus |
| Log compaction | Latest value by key | State change topics | Confusing compaction with time retention |
Kafka answer signals
Ordering, replay, and operations are the highest-value areas.
Prepare by drawing a record's path from producer to broker to consumer. Then explain ordering, replay, failure handling, and lag.
Kafka interview prep flow
Most rounds reward clear reasoning more than memorized phrasing.
A strong Kafka coverage names the partition key, expected ordering, consumer group behavior, offset commit point, and retry path. production-ready answers also cover schema compatibility, idempotent producers, dead-letter topics, lag monitoring, retention, compaction, and what happens during broker or consumer failure.
Kafka guarantees order within a partition, not across the whole topic.
Retries and failures can create duplicate processing. Consumers should be idempotent when the business action requires it.
Consumer lag may come from input spikes, slow processing, rebalances, bad partitions, or slow sinks.
Event producers and consumers evolve independently, so compatibility rules are part of the design.
6 questions, about 4 minutes. Score 70% or higher to earn a shareable certificate.
Use this Kafka bank for architecture and incident answers, then practice SQL, Python, and pipeline tasks with Hyring's AI Coding Interviewer.
See Hyring AI Coding Interviewer