Tran Triet
Tran Triet

Reputation: 1307

How to load balance Kafka consumers within a consumer group

Scenario

Question

  1. Does Kafka support a mechanism to automatically send message to a partition whose consumer is free?
  2. If it doesn't, what is the common approach to this scenario?

Upvotes: 3

Views: 1060

Answers (1)

OneCricketeer
OneCricketeer

Reputation: 191710

Although you could implement a custom Assignor class, by default, consumption is only based on assignment, not by load; such information is not communicated back to the group coordinator. Plus, shuffling around constantly based on load would likely cause frequent group rebalances, causing consumption to be even slower

Regarding length-of-processing, I am not aware of any way your consumer would be able to inspect message before partition assignment and polling such records. Therefore, you'd need to decouple your processing logic from the actual poll loop if you'd like to improve processing times.

Upvotes: 2

Related Questions