---
title: "Kafka session.timeout.ms: detecting dead consumers"
description: "What Kafka consumer session.timeout.ms does: how long the group waits for heartbeats before it evicts a member and rebalances, its 45 s default, and tuning."
url: https://monedula.dev/kafka-simulator/configs/session-timeout-ms/
---

# session.timeout.ms: how long a dead consumer keeps its partitions

Consumer config · default 45000 (45 seconds) · Apache Kafka 4.3.

session.timeout.ms is how long the group coordinator waits for a heartbeat from a consumer before it removes the member and gives its partitions to the rest of the group (default 45000, 45 seconds). A crashed consumer keeps its partitions, unread, for that long. It applies to the classic group protocol; with group.protocol=consumer the broker setting group.consumer.session.timeout.ms applies instead.

## At a glance

- Config: `session.timeout.ms` (consumer)
- Default: 45000 (45 seconds)
- Valid values: Within the broker group.min.session.timeout.ms (6000) and group.max.session.timeout.ms (1800000)
- Also set at: With group.protocol=consumer (KIP-848), the session timeout is the broker setting group.consumer.session.timeout.ms (default 45000), and the client value is not used.
- Reference: [Apache Kafka documentation](https://kafka.apache.org/43/configuration/consumer-configs/#consumerconfigs_session.timeout.ms)

## What it does

A consumer in a group sends heartbeats from a background thread every heartbeat.interval.ms (3 seconds by default). If the coordinator hears nothing for session.timeout.ms, it declares the member dead and rebalances its partitions onto the others. A clean shutdown sends a leave request, so only crashes, freezes and network partitions wait out the timeout. Heartbeats come from their own thread, so slow processing does not trip it; that is max.poll.interval.ms.

## The trade-off

A short timeout moves a dead consumer partitions quickly, but long garbage collection pauses or brief network trouble then cause needless rebalances. A long timeout rides those out, but after a real crash the partitions sit unread for the whole timeout while lag grows. Static membership (group.instance.id) lets a restarted consumer take back its partitions without a rebalance, as long as it returns within the timeout.

## Advice

- Keep heartbeat.interval.ms at no more than a third of session.timeout.ms.
- The 45 s default suits most groups; lower it only if partitions stalled for 45 s after a crash hurt more than occasional extra rebalances.
- For rolling restarts without rebalances, use static membership with a session timeout longer than a restart.

## See it in the simulator

- [Kafka consumer crash and session.timeout.ms](https://monedula.dev/kafka-simulator/scenarios/consumer-crash/) (Consumer crash & session timeout), step 3: c1 crashed · p0 stalls, c2 keeps consuming. c1 crashed at t=1000 but still owns p0 until session.timeout.ms (2000 ms here; timings are compressed, real brokers require at least 6 s) elapses. New records on p0 are NOT consumed - its lag grows - while c2 keeps draining p1. This partial stall is what makes a crash different from a clean leave. [Open at this step](https://monedula.dev/kafka-simulator/playground/?scenario=02.3.1&t=2)
- [Kafka static membership: group.instance.id avoids rebalances](https://monedula.dev/kafka-simulator/scenarios/static-membership/) (Static membership: avoid rebalance), step 5: static member rejoins in time. s2 restarts with the SAME instance.id at t=2800 - within session.timeout.ms of its crash (1800 ms < 2000 ms here; timings are compressed, real brokers require at least 6 s) - so the coordinator’s held slot lets it resume p1 in place with NO rebalance (s1 still owns only p0). d2 is still absent, its eviction one tick away. [Open at this step](https://monedula.dev/kafka-simulator/playground/?scenario=02.3.3&t=4)

## Related configs

- [Kafka max.poll.interval.ms: slow processing and rebalances](https://monedula.dev/kafka-simulator/configs/max-poll-interval-ms/)
- [Kafka auto.offset.reset: earliest vs latest](https://monedula.dev/kafka-simulator/configs/auto-offset-reset/)
- [Kafka read_committed vs read_uncommitted (isolation.level)](https://monedula.dev/kafka-simulator/configs/isolation-level/)
