Two ways out of the group#
Group membership has two separate liveness checks, and each one can eject a consumer that is still running:
- The poll interval. If the application does not call
poll()withinmax.poll.interval.ms(default 300000 ms, five minutes), the client leaves the group on purpose so that another member can take its partitions. This is the usual result of slow processing: a batch of up tomax.poll.recordsrecords (default 500) that takes longer than the interval to handle. When the application then tries to commit, it can get aCommitFailedException. KafkaConsumer: detecting consumer failures · Consumer configs - The session timeout. A background thread sends heartbeats. If the coordinator receives none for the session timeout, it removes the member and rebalances. With the classic protocol the client sets
session.timeout.ms(default 45000 ms) andheartbeat.interval.ms(default 3000 ms). With the newer consumer protocol (group.protocol=consumer) the broker sets them asgroup.consumer.session.timeout.ms(default 45000 ms) andgroup.consumer.heartbeat.interval.ms(default 5000 ms), and the client settings are not supported. Long process pauses, CPU starvation, network trouble to the coordinator and crashes all end here. Consumer configs · Broker configs · Consumer rebalance protocol
A third, nearby cause is churn from outside: pods restarting after out-of-memory kills, a rolling deploy, or an autoscaler adding and removing members. Each join and leave triggers a rebalance even though no timeout fired.
Why they look alike#
From the group's side, all three look like members leaving and joining, partitions moving, and lag growing while partitions are reassigned. The fixes point in different directions. Raising max.poll.interval.ms does nothing for a consumer that misses heartbeats, and raising the session timeout does nothing for one whose batches take six minutes. Restarts need neither.
Read the consumer's log first#
The Java client logs a warning when the poll interval expires. In the classic consumer it begins consumer poll timeout has expired. This means the time between subsequent calls to poll() was longer than the configured max.poll.interval.ms, and the newer consumer logs the same text with a capital C. If that line precedes each departure, the cause is processing time. AbstractCoordinator source · AbstractHeartbeatRequestManager source
If the line is missing and the process was alive, look for heartbeat failures: in the classic consumer, a heartbeat that failed with an unknown member ID error and a note that the client is resetting its generation. That means the coordinator had already removed the member. If the process was not alive, the log simply stops; look at why it stopped. AbstractCoordinator source
The client's metrics say the same thing in numbers. Under kafka.consumer:type=consumer-metrics, time-between-poll-max near or above max.poll.interval.ms points to slow processing. Under kafka.consumer:type=consumer-coordinator-metrics, rebalance-rate-per-hour and failed-rebalance-total show how often the member rebalances. Kafka monitoring
Read the group from outside#
kafka-consumer-groups.sh reads the group without changing it. --state prints the coordinator, the assignment strategy, the state and the member count; --members lists each member's CONSUMER-ID, host, client ID and partition count. Run both a few times a minute apart. Basic Kafka operations
bin/kafka-consumer-groups.sh --bootstrap-server BROKER:9092 --command-config CLIENT_PROPERTIES \
--describe --group GROUP --state
bin/kafka-consumer-groups.sh --bootstrap-server BROKER:9092 --command-config CLIENT_PROPERTIES \
--describe --group GROUP --members
A healthy group reads Stable. A group in a loop keeps showing a rebalancing state (PreparingRebalance or CompletingRebalance for a classic group, Assigning or Reconciling for a consumer-protocol group), and the describe command warns that the group is rebalancing. New CONSUMER-ID values on the same host between reads mean the same process rejoined as a new member. GroupState source · ConsumerGroupCommand source
If the consumers run on Kubernetes, check restarts and the last termination reason. An out-of-memory kill shows OOMKilled with exit code 137. Assign memory resources
kubectl get pods --namespace NAMESPACE --selector app=CONSUMER_APP
kubectl get pod POD --namespace NAMESPACE --output jsonpath='{.status.containerStatuses[*].lastState.terminated}'
Decide which timeout fired#
| Consumer log | Time between polls | Pod restarts | Points to |
|---|---|---|---|
| Poll timeout warning | Above the interval | None | Slow processing per batch |
| Heartbeat failed, generation reset | Normal | None | Session timeout: pauses or network |
| Log stops, then a fresh start | Rising | Crashes or restarts | |
| Nothing unusual | Normal | None, but members change | Deploys or autoscaling |
A worked example: two rebalance loops#
This example is illustrative. The fictional group payments-settler has four members on Kubernetes, reading payments with the classic protocol and default timeouts. Both incidents show the group rebalancing every few minutes from 14:00 UTC.
In the first incident, each member logs consumer poll timeout has expired about five minutes after its last poll, then rejoins. time-between-poll-max reads 325 seconds. Since 14:00, each record waits on a fraud API call that takes about 650 ms, and a full batch of 500 records needs about 325 seconds. The member leaves, rejoins, receives a batch, and runs out of time again. The fix is on the consumer: smaller batches through max.poll.records, or processing off the poll thread with paused partitions as the client documentation describes. Then ask why the fraud API slowed down: is the latency the client's or the server's?
In the second incident, no poll timeout warning appears. Pod restarts climb, and the last termination reads OOMKilled, exit code 137. Each restart removes a member and adds a new one. No timeout setting will help; the memory limit or the consumer's memory use is the problem.
Limits#
The log lines quoted here come from the Java client. Other clients use their own wording and settings, so check their documentation for the equivalents. With static membership (group.instance.id), a member that exceeds the poll interval does not lose its partitions at once; they move after the session timeout. A loop also produces lag, so a lag alarm may be the first thing you see: lag from stalled or slow consumers. Consumer configs
If the loop began with a consumer release, compare the old and new revisions. Other dependency failures are covered in diagnosing runtime dependency failures.
Questions#
What is the default max.poll.interval.ms in Kafka?
300000 ms, five minutes. If the application does not call poll() within that time, the consumer leaves the group and its partitions are reassigned.
Does session.timeout.ms apply with the new consumer protocol?
No. With group.protocol=consumer, the session timeout and heartbeat interval are broker settings, group.consumer.session.timeout.ms and group.consumer.heartbeat.interval.ms. The client's session.timeout.ms and heartbeat.interval.ms are not supported there.
Should I just raise max.poll.interval.ms?
Only if each batch's processing time is known and bounded. A larger value also delays rebalances, because a member joins a rebalance only inside poll(). Smaller batches or processing on another thread address the cause.