Can multiple Kafka consumers read the same message from a partition? - Big Data In Real World

Can multiple Kafka consumers read the same message from a partition?

What are broadcast variables in Spark and when to use them?
May 24, 2021
What is the difference between NameNode and Secondary NameNode?
May 28, 2021
What are broadcast variables in Spark and when to use them?
May 24, 2021
What is the difference between NameNode and Secondary NameNode?
May 28, 2021

Let’s redefine the question a little bit. Can multiple Kafka consumers from a consumer group read the same message from a partition?

The short answer to the above redefined question is No.

How is it possible? – Consumer offset

Consumer offset is used to track the messages that are consumed by consumers in a consumer group. A topic can be consumed by many consumer groups and each consumer group will have many consumers. A topic is divided into multiple partitions.

A consumer in a consumer group is assigned to a partition. Only one consumer is assigned to a partition. A consumer can be assigned to consume multiple partitions.

Consumer offset is managed at the partition level per consumer group. In summary –

  • Topic has many partitions
  • Topic can have many consumer groups
  • Only one consumer in a consumer group can be assigned to consume messages from a partition
  • A consumer offset is managed at the partition level per consumer group

So the rule in Kafka is only one consumer in a consumer group can be assigned to consume messages from a partition in a topic and hence multiple Kafka consumers from a consumer group can not read the same message from a partition.

Interested in learning more about consumer offset? Check out this post.

Big Data In Real World
Big Data In Real World
We are a group of Big Data engineers who are passionate about Big Data and related Big Data technologies. We have designed, developed, deployed and maintained Big Data applications ranging from batch to real time streaming big data platforms. We have seen a wide range of real world big data problems, implemented some innovative and complex (or simple, depending on how you look at it) solutions.

8 Comments

  1. […] A consumer can be assigned to consume multiple partitions. So the rule in Kafka is only one consumer in a consumer group can be assigned to consume messages from a partition in a topic and hence multiple Kafka consumers from a consumer group can not read the same message from a partition.Click to see full answer […]

  2. […] Can one consumer read from multiple partitions? […]

Can multiple Kafka consumers read the same message from a partition?
This website uses cookies to improve your experience. By using this website you agree to our Data Protection Policy.

Hadoop In Real World is now Big Data In Real World!

X