David Faizulaev
David Faizulaev

Reputation: 5721

Kafkajs - multiple consumers reading from same topic and partition

I'm planning to use Kafkajs https://kafka.js.org/ and implement it in a NodeJs server. I would like to know what is the expected behavior in case I have 2 (or more) instances of the server running, each of them having a consumer which is configured with the same group id and topic?

Does this mean that they might read the same messages? Should I specify a unique consumer group per each server instance ?

I read this - Multiple consumers consuming from same topic but not sure it applies for Kafkajs

Upvotes: 0

Views: 2260

Answers (1)

OneCricketeer
OneCricketeer

Reputation: 191681

It's not possible for a single consumer group to have multiple consumers reading from overlapping partitions in any Kafka library. If your topic only has one partition, only one instance of your application will be consuming it, and if that instance dies, the group will rebalance and the other instance will take over (potentially reading some of the same data, due to the nature of at-least-once delivery, but it's not at the same time as the other instance)

Upvotes: 1

Related Questions