Video in progress
If two different consumer groups read the same topic, are messages split between them?
No. Each group receives all the messages in the topic for itself and keeps its own offsets independently. Messages are split only among the consumers inside a single group.
📖 Answer
This often causes an accidental bug. Say two different services were started with the same group.id by mistake: email-service and sms-service are both in the notifications group. Now the partitions are divided between them: some messages go only to email, others only to SMS. No error shows up, only customers complain.
The rule is simple: group.id means "who is reading". One logical service = one group. In many projects it's taken from the application name:
spring:
kafka:
consumer:
group-id: ${spring.application.name}
There's a reverse mistake too: a random group.id per pod (for example, with the hostname added). Then every pod gets every message and the work is repeated 5 times. Sometimes this is intentional, for example to refresh the local cache of every instance, but it has to be intentional.
Sign up to mark studied questions and save your progress.