Apache Kafka interview questions

27 questions from the Apache Kafka: Event Streaming from Basics to Production course, each with the correct answer and an explanation. Try to answer before you open the answer.

Kafka Basics

1. What happens to a record after one consumer reads it?

  1. It moves to another topic automatically
  2. It is deleted immediately
  3. It stays in the topic until retention removes it, and others can still read it
  4. It is encrypted
Show answer

Answer: It stays in the topic until retention removes it, and others can still read it

Kafka is a log: reading does not remove data, so many consumers can replay it.

Lesson: What Kafka Is

2. Where is record ordering guaranteed?

  1. Within a single partition
  2. Across all partitions of a topic
  3. Across all topics
  4. Nowhere
Show answer

Answer: Within a single partition

Kafka orders records per partition; cross-partition order is not guaranteed.

Lesson: Topics, Partitions, Offsets and Records

3. What is the ISR?

  1. The producer buffer
  2. The list of consumers
  3. A kind of topic
  4. The replicas that are fully caught up with the leader
Show answer

Answer: The replicas that are fully caught up with the leader

In-sync replicas are eligible to take over as leader without losing acknowledged data.

Lesson: Brokers, Replication and KRaft

4. In the output, both `user-1` records are in the same partition. Why?

  1. Kafka picks partitions randomly each time
  2. The same key is hashed to the same partition
  3. Partitions are chosen alphabetically by value
  4. It was a coincidence of the broker
Show answer

Answer: The same key is hashed to the same partition

The default partitioner hashes the key, so equal keys always map to one partition.

Lesson: Your First Topic: Create, Produce, Consume

Producers

5. How does the default partitioner choose a partition for a keyed record?

  1. A random number
  2. murmur2 hash of the key modulo the partition count
  3. The size of the value
  4. The broker with most free disk
Show answer

Answer: murmur2 hash of the key modulo the partition count

Hashing the key makes the choice deterministic: same key, same partition.

Lesson: Keys and Partitioning

6. Which setting makes the producer wait for all in-sync replicas?

  1. compression.type=none
  2. acks=0
  3. linger.ms=0
  4. acks=all
Show answer

Answer: acks=all

acks=all acknowledges only after every in-sync replica has the record.

Lesson: Acknowledgements, Retries and Idempotence

7. What does a small `linger.ms` such as 10 usually do?

  1. Lets batches fill a little, raising throughput at small latency cost
  2. Disables retries
  3. Encrypts data
  4. Deletes old records
Show answer

Answer: Lets batches fill a little, raising throughput at small latency cost

Waiting briefly lets more records join a batch, improving efficiency.

Lesson: Batching and Compression

8. Which schema change is generally backward-compatible?

  1. Changing a field type from string to int
  2. Renaming a required field
  3. Adding an optional field with a default
  4. Removing a required field
Show answer

Answer: Adding an optional field with a default

A defaulted optional field lets new readers handle old records.

Lesson: Serialization and Schemas

Consumers and Consumer Groups

9. What is consumer lag?

  1. Network latency to the broker
  2. The age of the topic
  3. Log-end offset minus the committed offset
  4. The number of partitions
Show answer

Answer: Log-end offset minus the committed offset

It counts how many records are written but not yet processed by the group.

Lesson: Consumer Groups and Committed Offsets

10. A topic has 6 partitions and a group has 8 consumers. What happens?

  1. 6 consumers get one partition each and 2 sit idle
  2. All 8 share partitions equally
  3. The group fails to start
  4. Kafka creates 2 new partitions automatically
Show answer

Answer: 6 consumers get one partition each and 2 sit idle

A partition goes to at most one consumer per group, so extra consumers are idle.

Lesson: Assignment and Rebalancing

11. Which order gives at-least-once processing?

  1. Commit twice
  2. Commit the offset, then process
  3. Never commit
  4. Process the record, then commit the offset
Show answer

Answer: Process the record, then commit the offset

A crash between processing and commit causes a re-read, never a loss.

Lesson: Commits and Delivery Semantics

12. Why use a dead-letter topic?

  1. To speed up the broker
  2. To park permanently failing records so the partition keeps moving
  3. To delete all errors silently
  4. To increase partitions
Show answer

Answer: To park permanently failing records so the partition keeps moving

Parked records can be inspected and replayed without blocking healthy traffic.

Lesson: Failures, Retries and Dead-Letter Topics

Designing Topics

13. What is true about changing a topic's partition count?

  1. You can freely decrease it
  2. You can increase it but not decrease it, and key placement may change
  3. It never affects ordering
  4. It is fixed forever
Show answer

Answer: You can increase it but not decrease it, and key placement may change

Partitions can only grow, and a different modulus changes where existing keys map.

Lesson: Choosing the Partition Count

14. What does a record with a key and a null value do on a compacted topic?

  1. Does nothing at all
  2. Duplicates the key
  3. Deletes the topic
  4. Marks that key for deletion (a tombstone)
Show answer

Answer: Marks that key for deletion (a tombstone)

A tombstone tells compaction to eventually remove that key entirely.

Lesson: Retention and Log Compaction

15. Why disable auto topic creation in production?

  1. So topics are created deliberately with proper partitions and replication
  2. Because it is slower
  3. Auto creation is illegal
  4. It uses more memory only
Show answer

Answer: So topics are created deliberately with proper partitions and replication

A typo in a topic name would otherwise silently create a new topic with default settings.

Lesson: Naming, Ownership and Topic Hygiene

Durability and Reliability

16. With replication factor 3 and min.insync.replicas=2, how many broker failures can writes survive?

  1. Three
  2. Two
  3. One
  4. None
Show answer

Answer: One

Writes need two in-sync replicas, so only one of the three may be down.

Lesson: min.insync.replicas and Availability

17. A broker fails. Where does the new partition leader come from?

  1. From the producer
  2. From a random consumer
  3. From the in-sync replicas of that partition
  4. A new partition is created
Show answer

Answer: From the in-sync replicas of that partition

Only in-sync replicas are eligible, so the new leader has all acknowledged records.

Lesson: Failure Scenarios and Leader Election

18. What does `isolation.level=read_committed` do for a consumer?

  1. Hides records from aborted or open transactions
  2. Encrypts the records
  3. Deletes old records
  4. Speeds up the broker
Show answer

Answer: Hides records from aborted or open transactions

Only committed transactional data is delivered to the consumer.

Lesson: Idempotent Producers and Transactions

Streams, Connect and the Ecosystem

19. What is Kafka Connect for?

  1. Formatting code
  2. Encrypting disks
  3. Replacing brokers
  4. Moving data between Kafka and other systems using connectors
Show answer

Answer: Moving data between Kafka and other systems using connectors

Connect provides ready-made, scalable source and sink integrations.

Lesson: Kafka Connect

20. What does a tumbling window do?

  1. Drops all events
  2. Groups events into fixed, non-overlapping time intervals
  3. Overlaps every window by 99%
  4. Sorts topics alphabetically
Show answer

Answer: Groups events into fixed, non-overlapping time intervals

Tumbling windows split time into back-to-back fixed buckets.

Lesson: Stream Processing: Kafka Streams, Flink and ksqlDB

Operations and Security

21. What does a non-zero under-replicated partition count indicate?

  1. The cluster is idle
  2. Some replicas are not keeping up, so durability is reduced
  3. Consumers are too fast
  4. Compression is off
Show answer

Answer: Some replicas are not keeping up, so durability is reduced

It means fewer in-sync copies exist than the replication factor, which needs attention.

Lesson: Monitoring What Matters

22. Which provides least-privilege access to topics?

  1. Opening the broker port to the internet
  2. One shared admin user for all services
  3. Disabling authentication
  4. ACLs granting only needed operations on specific topics
Show answer

Answer: ACLs granting only needed operations on specific topics

Per-principal, per-resource permissions limit what any one service can do.

Lesson: Security: TLS, SASL and ACLs

23. Why upgrade brokers one at a time?

  1. To keep enough in-sync replicas available so writes continue
  2. Brokers cannot restart together
  3. It makes upgrades free
  4. Only for managed services
Show answer

Answer: To keep enough in-sync replicas available so writes continue

Restarting all brokers at once would drop below min.insync.replicas and halt writes.

Lesson: Capacity, Upgrades and Managed Services

Putting It Together

24. Why is `order_id` a good key in the case study?

  1. It disables compression
  2. It makes every record unique across topics
  3. All events of one order go to one partition and stay ordered
  4. Kafka requires it
Show answer

Answer: All events of one order go to one partition and stay ordered

Per-entity ordering needs the entity ID as the key.

Lesson: Case Study: Order Events for an E-commerce Platform

25. Consumer lag keeps growing. Which is a likely first check?

  1. Whether topics have long names
  2. Whether the font is readable
  3. Whether consumers are slow or stuck, or whether partitions/consumers are too few
  4. Deleting the topic
Show answer

Answer: Whether consumers are slow or stuck, or whether partitions/consumers are too few

Lag grows when processing is slower than production, so check consumer speed, errors, rebalances and parallelism.

Lesson: Revision: Cheat Sheet and Self-Check

26. Which setup survives one broker failure without losing acknowledged writes?

  1. rf=3, min.insync.replicas=2, acks=all
  2. rf=1, acks=1
  3. rf=2, min.insync.replicas=2, acks=all
  4. acks=0 with rf=3
Show answer

Answer: rf=3, min.insync.replicas=2, acks=all

Three replicas with two required in sync let writes continue after one failure and keep data on two brokers.

Lesson: Revision: Cheat Sheet and Self-Check

27. You want the processing of a record to be safe if it is delivered twice. What do you do?

  1. Add more partitions
  2. Commit before processing
  3. Disable retries on the broker
  4. Make the handler idempotent, for example upsert by a unique key
Show answer

Answer: Make the handler idempotent, for example upsert by a unique key

Idempotent handling makes duplicate delivery harmless.

Lesson: Revision: Cheat Sheet and Self-Check

← Back to the course