Kafka Questions with Answers

14 practice questions on Kafka (Big Data (Hadoop & Spark)) with answers and step-by-step solutions. Try 10 samples below, then practise all 14 free in the AptiNest app.

Sample questions

Question 1Easy

In Kafka, messages are organised into named streams called:

  1. tables
  2. topics
  3. buckets
  4. queues only

Answer: B. topics

Explanation

Producers write to topics and consumers read from them.

Step-by-step solution

  1. Messages in Kafka are grouped into named streams.
  2. These named streams are called topics.
  3. Producers send messages to topics.
  4. Consumers read messages from topics.
  5. So the correct answer is topics.

Why the other options are wrong

  • A. Tables are how a database stores data; Kafka organises messages into topics.
  • C. Buckets are not the Kafka term; messages are grouped into topics, which are split into partitions.
  • D. Queues only is wrong; Kafka uses topics, which are not just queues.

Question 2Easy

What does a Kafka consumer's offset represent?

  1. The position of the next message to read within a partition
  2. The size of a message in bytes in the topic, measured in bytes from the start of the log
  3. The replication factor
  4. The broker's IP address

Answer: A. The position of the next message to read within a partition

Explanation

Offsets let consumers resume from where they stopped.

Step-by-step solution

  1. Each message has an index in a partition.
  2. Consumer stores last position.
  3. Restart resumes from the offset.

Why the other options are wrong

  • B. Offset is a position, not a size.
  • C. Unrelated.
  • D. Not what it means.

Question 3Easy

In Apache Kafka, messages are published to named streams called

  1. Tables
  2. Buckets
  3. Blocks
  4. Topics

Answer: D. Topics

Explanation

Producers write to topics and consumers read from them; topics are split into partitions.

Step-by-step solution

  1. Producer sends to a topic.
  2. Topic split into partitions.
  3. Consumers read from it.

Why the other options are wrong

  • A. Tables are a database concept.
  • B. Buckets belong to Hive or object stores.
  • C. Blocks are an HDFS concept.

Question 4Medium

In a Kafka consumer group, each partition of a topic is consumed by

  1. Every consumer in the group, and each consumer in the group sees every message of that partition
  2. Exactly one consumer in the group at a time
  3. A random consumer for each message
  4. No consumer until all are idle

Answer: B. Exactly one consumer in the group at a time

Explanation

Within a group partitions are divided among members; separate groups each get all messages.

Step-by-step solution

  1. Group shares partitions.
  2. One partition, one consumer in the group.
  3. Different groups read independently.

Why the other options are wrong

  • A. That would duplicate processing; it applies across different groups.
  • C. Assignment is per partition.
  • D. Consumers get partitions as they join.

Question 5Medium

Within a Kafka topic, message ordering is guaranteed

  1. Only within a single partition
  2. Across all partitions of the topic
  3. Never
  4. Only across different topics

Answer: A. Only within a single partition

Explanation

Messages with the same key go to the same partition so their relative order is kept.

Step-by-step solution

  1. Each partition is an ordered log.
  2. Key hash picks the partition.
  3. Same key, same order.

Why the other options are wrong

  • B. Different partitions have no global order.
  • C. Order is kept per partition.
  • D. No ordering across topics.

Question 6Medium

Which delivery guarantee does a Kafka producer config with acks=all aim to improve?

  1. Lower latency, because the producer sends the message and does not wait for any reply
  2. Message ordering across topics
  3. Smaller messages
  4. Durability, because the leader waits for all in-sync replicas to acknowledge

Answer: D. Durability, because the leader waits for all in-sync replicas to acknowledge

Explanation

With acks=all a write is acknowledged only after being on all in-sync replicas.

Step-by-step solution

  1. Producer sends.
  2. Leader waits for in-sync replicas.
  3. Acknowledges: data safe.

Why the other options are wrong

  • A. Waiting for more replicas adds latency.
  • B. Not related.
  • C. Not related.

Question 7Medium

A Kafka topic is split into partitions mainly to:

  1. Allow parallelism and scale across brokers
  2. Encrypt messages
  3. Remove the need for consumers
  4. Guarantee global ordering across the topic

Answer: A. Allow parallelism and scale across brokers

Explanation

Partitions spread load; ordering is guaranteed only within a partition.

Step-by-step solution

  1. Partitions allow multiple brokers to process messages in parallel.
  2. This enables scaling across different servers in the cluster.
  3. Each partition can handle its own data independently.
  4. Parallel processing improves performance and efficiency.
  5. The correct answer is Allow parallelism and scale across brokers.

Why the other options are wrong

  • B. Encryption is handled by TLS and settings, not by splitting a topic into partitions.
  • C. Partitions do not remove consumers; consumers still read messages from the partitions.
  • D. Partitions give ordering within a partition, not global ordering across the whole topic.

Question 8Medium

Kafka retains messages

  1. Only until the first consumer reads them and deleted as soon as the first consumer in the group has read them
  2. For a configured retention period or size, regardless of whether they were consumed
  3. Forever without limit always
  4. Only in memory

Answer: B. For a configured retention period or size, regardless of whether they were consumed

Explanation

This allows replay and multiple independent consumers over the same data.

Step-by-step solution

  1. Messages are appended to logs.
  2. Deleted by time or size policy.
  3. Consumption does not remove them.

Why the other options are wrong

  • A. Kafka does not delete on read.
  • C. Retention is configurable.
  • D. They are persisted to disk logs.

Question 9Hard

Two consumers in the SAME consumer group read a topic with 4 partitions. How are partitions normally assigned?

  1. Every consumer reads all partitions
  2. Only one consumer reads, the other idles always
  3. Messages are duplicated to both for load balancing
  4. Each partition goes to exactly one consumer in the group

Answer: D. Each partition goes to exactly one consumer in the group

Explanation

Within a group each partition has a single consumer, so the group shares the work; separate groups each get all messages.

Step-by-step solution

  1. Each consumer group gets unique partitions.
  2. Partitions are split between consumers in the same group.
  3. Each partition is assigned to exactly one consumer in the group.
  4. So, each partition goes to exactly one consumer in the group.
  5. Final answer: Each partition goes to exactly one consumer in the group.

Why the other options are wrong

  • A. Consumers in one group do not each read all partitions; that would duplicate work.
  • B. The other consumer is not idle always; partitions are shared, so both work when there are partitions.
  • C. Messages are not duplicated within one group; each message goes to one consumer in the group.

Tip: Remember: One consumer per partition in the same group.

Question 10Hard

With a topic replication factor of 3, a partition has

  1. Three equal leaders accepting writes which each accept writes for the partition at the same time
  2. One copy and two empty backups
  3. One leader replica handling reads and writes and two followers copying from it
  4. Three consumers

Answer: C. One leader replica handling reads and writes and two followers copying from it

Explanation

If the leader broker fails, an in-sync follower is promoted to leader.

Step-by-step solution

  1. Leader takes writes.
  2. Followers replicate.
  3. In-sync follower is elected on failure.

Why the other options are wrong

  • A. Each partition has a single leader.
  • B. Followers contain replicated data.
  • D. Replicas are broker-side copies.

Practise all 14 questions free

The full question bank with timed practice, progress tracking and Vidya, your AI tutor. Free, no ads.

Open this topic in the app →

Related topics

See all Big Data (Hadoop & Spark) topics · All topics