Consumer Group Vs Partition

Each consumer group will read 1 partition.

Pasted image 20231128230925.png

So if you have 2 consumers in 2 different consumer groups, they will both read the same messages from Kafka

In order for 2 consumers interchangely consume the message, you need to put them in the same partition.

Example:

  1. So for example you have a topic mytopic with 12 partition. You put 2 consumers in the same consumer group:
    • Each consumer will consume 6 partitions
  2. You have a topic mytopic with 12 partition. You put 2 consumers in 2 different consumers group:
    • Each consumer will consume 12 partitions (duplication)