Kafka is a distributed event streaming platform that stores messages in an ordered, replicated log so many systems can publish and consume them independently. Topics include producers and consumers, partitions and ordering, retention and log compaction, delivery semantics, idempotence and exactly-once processing, dead letter queues, event sourcing, stream processing and operations.
All 37 Kafka quiz questions below come with a short explanation, visible right on the page — no sign-in needed. They're grouped by beginner and intermediate levels and 17 subtopics, so you can revise one part at a time. Choose Try Kafka quiz above to take a scored run and review the questions you got wrong.
What is the unit of parallelism for a Kafka topic?
A.The partition
B.The consumer group — the groups run in parallel with each other
C.The topic — each topic is handled by its own consumer
D.The broker — adding brokers increases the parallelism
Answer: A
Partition. Within a consumer group, each partition is read by only one consumer. So a topic with 6 partitions supports at most 6 working consumers; the 7th consumer sits idle.
Once a consumer reads a message, is it removed from Kafka?
A.Yes, the message is deleted right after being delivered
B.It is only deleted once every consumer group has read past it
C.No — the message stays until the retention period expires
D.Yes, deleted once the consumer commits the offset
Answer: C
No. Kafka is a log retained by time (retention.ms, default 7 days) or by size. A consumer only moves its own offset cursor; the data stays there for other groups to read or for re-reading.
A.The number of failed messages the consumer could not handle
B.The distance between the latest offset and the offset the consumer has read
C.The network latency between the consumer and the broker
D.The average time to process one message
Answer: B
The number of records between the partition's end offset and the consumer's committed offset — i.e. how many records the consumer is behind. This is the most important health metric of a Kafka pipeline.
How is the partition chosen when a producer sends a message with no key?
A.Pick an available partition with the sticky partitioner
B.The broker picks the least busy partition
C.It always writes to partition 0 as the default
D.It hashes the value's content to pick a partition
Answer: A
The producer spreads records evenly in batches (sticky partitioner: fills one batch into a partition, then moves to another). With a key, partition = hash(key) % number of partitions, so the same key always goes to the same partition.
Two different consumer groups subscribe to the same topic — how is data divided?
A.The two groups split the messages between them
B.The group that subscribed first gets everything and the other waits
C.Whichever group commits offsets faster receives more
D.Each group receives every message of the topic in full
Answer: D
Each group receives every message, independently, because offsets are stored per group. Work is only divided among consumers *within the same* group — this is how Kafka supports both pub/sub and queuing.
A.Joining several Kafka clusters into one large cluster
B.Transforming data in flight with joins and aggregations
C.Moving data into and out of Kafka with ready-made connectors
D.Managing clients' connections to the brokers more efficiently
Answer: C
Moves data into/out of Kafka using connectors declared via configuration: a source connector reads from Postgres/MySQL/S3 and writes to a topic, a sink connector reads a topic and writes to Elasticsearch/S3/a data warehouse.
A.Each message is written 3 times into the same partition
B.3 consumer groups are permitted to read that topic
C.Each partition has 3 copies on 3 different brokers
D.The topic is split into 3 partitions when created
Answer: C
Each partition exists in 3 replicas on 3 different brokers: one leader handles writes, the followers replicate it and can be elected leader on failure. Losing one broker still leaves 2 replicas, so the cluster keeps running.
A.A unique identifier of the record across the whole topic
B.The timestamp when the broker accepted the record
C.An increasing sequence number of the record within one partition
D.The record's byte position in the log file on disk
Answer: C
A monotonically increasing sequence number within a partition, assigned by the broker on write. Only the tuple (topic, partition, offset) uniquely identifies a record — offset alone does not, since every partition starts at 0.
Creating a topic in production — which settings should you specify?
A.How many consumer groups will read it and their names
B.The partition count, the replication factor and the retention period
C.Which broker will hold each partition's leader
D.The topic's maximum size and maximum record count
Answer: B
--partitions (max parallelism), --replication-factor (fault tolerance, usually 3), and retention.ms or retention.bytes. Don't rely on defaults, since cluster defaults rarely match what the topic needs.
C.The order in which the consumers receive messages
D.Consumers with the same id share the partitions and the offsets
Answer: D
Consumers with the same group id split the partitions among themselves and share the stored read position. Changing the id means creating a new consumer side that starts from the position defined by config — usually the beginning or the end of the topic.
At what scope does Kafka guarantee message ordering?
A.Within a consumer group, in the order received
B.Within a broker, by the time messages arrived at it
C.Within a topic, regardless of how many partitions
D.Within one partition
Answer: D
Only within a single partition. To keep events of the same entity in order, write them with the same key (e.g. orderId) — same key means same partition.
A topic has 3 partitions and the consumer group has 5 consumers. What happens?
A.3 consumers work and 2 sit idle
B.All 5 consumers share the messages of the 3 partitions evenly
C.Kafka raises the partition count to 5 to match
D.The 2 extra consumers are rejected by the group with an error
Answer: A
3 consumers each get one partition, 2 consumers are completely idle. They don't fail and stay in the group — useful as backups, since if a consumer dies, the rebalance assigns its partition to an idle consumer.
A.It waits for every broker in the cluster to receive a copy
B.It waits for the message to be fsynced to disk before returning
C.It waits for every consumer to confirm it has processed the message
D.It waits for every in-sync replica to acknowledge, not just the leader
Answer: D
acks=1 only waits for the leader to write; if the leader dies before a replica fetches the data, the message is lost. acks=all waits for all replicas in the ISR to acknowledge, so it's more durable at the cost of higher latency.
A.Every record but compressed with gzip to save space
B.The first record for each key as a marker
C.The records within the most recent retention window
D.The newest record for each key
Answer: D
The latest record for each key; older records with the same key are gradually cleaned up. The log becomes current state rather than history — used for table-like topics: user info, config, inventory.
A consumer takes 6 minutes per message while max.poll.interval.ms stays at the 5-minute default. Result?
A.The message is moved to a dead-letter topic after the timeout
B.The group considers the consumer dead and rebalances, so the messages are reprocessed
C.The consumer keeps its partitions because heartbeats run on their own thread
D.The broker extends the timeout for a consumer that is processing slowly
Answer: B
The consumer gets kicked out of the group, the group rebalances, and that message is handed to another consumer — so it gets reprocessed, potentially in an infinite loop. This is the classic cause of "constant rebalancing".
What risk comes with automatic offset commits (enable.auto.commit=true)?
A.The offset is committed twice so the message is processed twice
B.The consumer can no longer read from the beginning of the topic
C.The broker must store extra data so it slows down noticeably
D.The offset may be committed before processing finishes, so messages are lost
Answer: D
Offsets are committed on a time interval, not according to actual processing progress. If that interval falls mid-processing and the consumer dies, messages that were committed but not yet processed will never be read again — silent data loss.
What does enable.idempotence=true on the producer prevent?
A.Duplicate records when the producer retries after a network error
B.A consumer reprocessing a message it already read
C.Messages lost when a partition's leader changes
D.Two different producers writing the same content to the topic
Answer: A
Duplicates caused by producer retries: the network fails after the broker has written but the response doesn't come back, the producer resends and creates a second record. An idempotent producer attaches a producer id + sequence number so the broker can discard the duplicate.
A malformed message makes the consumer throw repeatedly. What is the right handling?
A.Push it to a dead-letter topic, commit the offset and move on
B.Retry forever because no data may be lost
C.Delete the message from the topic with an admin command
D.Catch the error, ignore it and record nothing
Answer: A
Dead-letter topic: write the bad record along with error info to a separate topic, commit the offset, then continue processing. Retrying forever blocks the entire partition — records behind it don't get processed even though they're perfectly valid.
A.When you need the lowest latency for a single message
B.When you need priority queues and per-message TTLs
C.When you need to route messages by complex patterns
D.When you need to retain and replay the event history with several independent consumers
Answer: D
When the data is an event stream that needs to be retained: multiple independent consumers reading the same source, needing to replay history, very high throughput. RabbitMQ is better suited for work queues with complex routing, priorities, per-message TTL.
A.Every replica of the partition, including those lagging behind
B.The replicas keeping up with the leader within the allowed time window
C.The replicas that have fsynced the data to disk
D.The replicas on the same rack as the leader
Answer: B
The set of replicas that are keeping up with the leader (not lagging beyond replica.lag.time.max.ms). acks=all waits for exactly this set, and when a new leader must be chosen, only replicas in the ISR are eligible if you don't want to lose data.
What is the effect of raising linger.ms from 0 to 20?
A.The producer buffers messages longer if the broker dies
B.Larger batches raise throughput at the cost of a little extra latency
C.Consumers receive messages 20ms sooner
D.The producer retries faster on a transient error
Answer: B
The producer waits up to 20ms to gather more records into a batch: fewer requests, better compression, higher throughput, at the cost of up to 20ms added latency. For batch pipelines this is a very worthwhile trade-off.
You need an existing consumer group to reprocess a topic from the beginning. How?
A.Stop the consumers and reset the group's offsets to earliest
B.Delete the topic and rewrite all the data into it
C.Set auto.offset.reset=earliest and restart the consumers
D.Raise the topic's retention so the old data reappears
Answer: A
Stop all consumers in the group, then run kafka-consumer-groups.sh --reset-offsets --to-earliest --execute. auto.offset.reset=earliestdoes not help here because the group already has committed offsets — it only applies to new groups.
What does UnderReplicatedPartitions greater than zero mean?
A.The configured replica count exceeds the number of brokers in the cluster
B.Some partitions have fewer in-sync replicas than configured
C.Some partitions are being compacted so they temporarily lack replicas
D.Some partitions have no consumer subscribed to them
Answer: B
Some partition has fewer replicas in the ISR than the replication factor. This is a top warning metric: a sustained value above 0 means the cluster is losing fault tolerance.
When should you use Kafka Streams instead of a plain consumer?
A.When you need higher throughput than a plain consumer
B.When you want to avoid managing offsets manually
C.When you need to write data out to an external system such as Elasticsearch
D.When you need stateful processing: joins and windowed aggregations
Answer: D
When processing is stateful: windowed counts, joining two streams, aggregating by key. Doing this yourself with a consumer usually means building a durable state store, recovering from failures, and handling late-arriving data.
The producer reports TimeoutException: Expiring N records. What does that mean?
A.The consumer cannot keep up so the broker refuses more
B.The records sat in the buffer past delivery.timeout.ms without being sent
C.The destination topic does not exist so the records are dropped
D.The record exceeds the maximum allowed size
Answer: B
The record was already in the producer's buffer but could not be sent within delivery.timeout.ms (2 minutes by default), so it was discarded. Common causes: broker unavailability, network congestion, or the application producing faster than the send rate.
Adding a new Avro field with a default value is which kind of compatibility?
A.Incompatible, so a new topic must be created
B.Compatible only if every consumer upgrades at the same time
C.Forward but not backward, so the producer must be upgraded first
D.Backward — a consumer on the new schema can read old data
Answer: D
Backward compatible: a consumer running the new schema can read records written with the old schema, because the missing field falls back to its default value. This is the default compatibility level of the Schema Registry.
When a new broker joins the cluster, does existing data move to it automatically?
A.Yes, but only for topics with compaction enabled
B.No — you must run a reassignment to move partitions onto it
C.Yes, Kafka rebalances the partitions itself within minutes
D.No, and there is no way to move the existing partitions either
Answer: B
No automatic movement. A new broker only receives partitions of topics created after it joined. To move existing data, run kafka-reassign-partitions.sh with a new assignment plan.
B.assign is faster because it skips authentication with the broker
C.subscribe reads from the start of the topic while assign reads from the end
D.subscribe joins a group and gets partitions assigned automatically
Answer: D
subscribe() joins a consumer group: Kafka assigns partitions and rebalances automatically when consumers join or leave. assign() specifies partitions directly — no group, no rebalance, and the application handles partitioning itself.
A consumer must stop reading one partition because the destination system is overloaded. What is used?
A.pause() that partition and resume() it when ready
B.Close the consumer and recreate it a few minutes later
C.Call sleep inside the processing loop to slow down
D.Stop calling poll until the destination system recovers
Answer: A
pause(partitions) then resume(partitions). The key point: keep calling poll() while paused — that keeps heartbeats and the max.poll.interval.ms limit satisfied, so the consumer is not kicked out of the group.
A.Replicating topics between two different Kafka clusters
B.Backing topics up to external storage such as S3 on a schedule
C.Creating a read-only copy of a topic to offload the leader
D.Replicating partitions between brokers within one cluster
Answer: A
Replicating data across clusters: a disaster-recovery cluster in another region, aggregating data from many regions into one analytics place, or migrating to a new cluster. It is built on Kafka Connect.
One topic for all event types, or one topic per event type?
A.Always split every type with no exceptions
B.Split by consumer: one topic per service
C.Split by type, unless the events need a shared ordering
D.Always use one shared topic for everything to keep it simple
Answer: C
By default, separate by event type — consumers subscribe only to what they need, with separate retention and schemas. Exception: events of the same entity whose relative order matters (OrderCreated, OrderPaid, OrderCancelled) should go in the same topic, with the same key.
How does Kafka control which topics a client may read or write?
A.The client.id the producer declares when connecting
B.ACLs attached to an authenticated principal
C.A separate password per topic set at creation
D.A list of IP addresses allowed to connect to the brokers
Answer: B
ACLs are tied to a principal from the authentication step (SASL or mTLS): each rule lets a principal perform an operation on a resource. Without authentication, ACLs are meaningless since anyone can claim to be anyone.
A topic keeps 7 days but broker disks are nearly full. The fastest safe fix?
A.Delete the old log files directly on the broker's disk
B.Delete the topic and recreate it with a smaller retention
C.Reduce retention.ms on the topic taking the most disk
D.Lower the replication factor to 1 to save space
Answer: C
Reduce retention.ms (or set retention.bytes) for the biggest topics using kafka-configs.sh --alter. The change takes effect immediately, and the broker will clean up expired segments on the next cleanup cycle. Never delete log files by hand.
A.The group's committed offset was deleted from the broker
B.The consumer read an offset beyond the partition's last one
C.The partition was moved to another broker after a reassignment
D.The offset it wants to read has been cleaned up by retention
Answer: D
The consumer is asking for an offset that no longer exists — the data there has been removed by retention. Classic scenario: the consumer died or was stopped for longer than the topic's retention, and when it comes back its old offset is gone.
You need to attach metadata (trace id, schema version) without putting it in the payload. What do you use?
A.Create a separate topic holding the corresponding metadata
B.Add fields to the record's key for easy lookup
C.Encode it in the topic name by convention
D.Record headers
Answer: D
Record headers — key-value pairs attached to each record, available since Kafka 0.11. They can be read without decoding the payload, making them ideal for trace ids, schema versions, or error info when pushing to a dead-letter topic.
Besides storage savings, what does producer-side compression provide?
A.It increases how many partitions a topic can have
B.It reduces the latency of each individual message
C.It reduces network bandwidth and raises throughput
D.It guarantees message ordering better
Answer: C
Compression happens on the producer side per batch, and the data stays compressed all the way to the consumer. That saves bandwidth between producer and broker, between brokers during replication, and between broker and consumer — not just disk space.
B.Limiting how many topics an application may create
C.Stopping one client consuming all the broker's bandwidth
D.Limiting each topic's storage size
Answer: C
They limit read/write bandwidth and request processing time per client or per user. The goal is to stop one application from consuming the whole cluster's capacity and affecting every other application — the noisy neighbor problem in a shared cluster.