Skip to content
Kafka Is FunProgress

AdvancedInternals Deep Dive

Explain the Kafka consumer's heartbeat threading model and how it relates to max.poll.interval.ms.

Reference answer

The consumer runs a background heartbeat thread that sends HeartbeatRequests to the Group Coordinator at heartbeat.interval.ms. The main thread calls consumer.poll() which does the actual fetch work. These are SEPARATE threads. The heartbeat thread keeps the consumer 'alive' in the group. However, the coordinator also tracks the time between consecutive poll() calls (not heartbeats) — if this exceeds max.poll.interval.ms, the consumer is kicked out even if heartbeats are healthy. This handles 'live-locked' consumers (heartbeating but not making progress on processing).

Expected key concepts: heartbeat thread, HeartbeatRequests, heartbeat.interval.ms, consumer.poll, max.poll.interval.ms, separate threads, live-locked, making progress, Group Coordinator, kicked out