Integration / Apache Kafka Interview questions
What happens when a consumer in a group fails to send a heartbeat in time?
Each consumer in a group periodically sends a heartbeat to the group coordinator (a role held by one of the brokers) to signal it's still alive and processing. If a consumer misses heartbeats for longer than session.timeout.ms, the coordinator considers it dead and removes it from the group, triggering a rebalance that redistributes its assigned partitions among the remaining live consumers.
session.timeout.ms=45000 heartbeat.interval.ms=3000 max.poll.interval.ms=300000
A separate, often-confused setting is max.poll.interval.ms: even if heartbeats (sent on a background thread in modern Kafka clients) keep arriving on time, a consumer that takes too long between calls to poll() — because its processing logic is stuck or too slow — is also considered as having left the group, since Kafka can no longer be sure it's actually making progress on records already handed to it. This is the most common cause of unexpected rebalances in production: slow per-record processing exceeding max.poll.interval.ms, not an actual network or process failure.
More Related questions...