Kafka incidents repeat. The same eight or nine symptoms account for most pages, and each has a short list of causes. This topic is the reference you want open at 3am.
First five minutes
Resist the urge to change settings. Establish where the problem lives.
1. Is anything offline?
kafka-topics.sh --describe --unavailable-partitions
2. Is durability at risk?
kafka-topics.sh --describe --under-replicated-partitions
3. Is it one group, one topic, or everything?
kafka-consumer-groups.sh --describe --group <g> (look PER PARTITION)
4. Is it produce-side or consume-side?
producer error/retry rate vs consumer lag trend
5. What changed?
deploys, partition count changes, new consumer groups, backfills
Question 3 does most of the work. A problem in one group is an application problem; a problem across all groups on one broker is a broker problem; a problem everywhere is a cluster or network problem.
Symptom to cause
| Symptom | Likely causes | What to check | First action |
|---|---|---|---|
| Lag rising steadily on all partitions of one group | Consumers slower than producers; downstream dependency slow; too few partitions for the work | Per-record processing time; partition count versus instance count | Speed up processing or add partitions (mind the key-mapping trap) |
| Lag rising on one partition only | Key skew / hot key; one wedged consumer instance; one slow broker | Per-partition lag; key distribution; that instance's logs | Fix the key granularity; restart or replace the stuck instance |
| Lag rising while consumers look idle | More consumer instances than partitions; consumer paused; deserialisation loop | Group describe: are some members assigned nothing? | Stop over-scaling; align instance count to partitions |
| Rebalance storm: group rebalances constantly, little progress | Processing exceeds max.poll.interval.ms; frequent pod restarts; session.timeout.ms too tight for GC pauses | Batch duration versus max.poll.records; restart events; GC logs | Lower max.poll.records first; then static membership and cooperative rebalancing |
| Under-replicated partitions non-zero and sustained | Slow or failing broker; disk saturation; network between brokers; replica fetcher starvation | Which broker leads the affected replicas; disk and network on it | Investigate that broker before touching topic config; you are one failure from write rejection |
| Frequent ISR shrink and expand | Followers repeatedly falling behind: I/O contention, GC pauses, network jitter, or a genuinely overloaded leader | ISR shrink rate; broker request latency; disk utilisation | Relieve load on the leader broker; check disk before assuming network |
Producers get NotEnoughReplicas | ISR fell below min.insync.replicas | Under-replicated partitions; broker availability | Restore the missing replica. Lowering min.insync.replicas trades away the durability you asked for |
| Disk pressure / broker near full | Retention or retention.bytes under-estimated; unexpected volume; a replica catching up; log cleaner not keeping up on compacted topics | Per-topic disk usage; retention settings; log cleaner health | Reduce retention on the largest low-value topic, then add capacity. Never delete segment files by hand |
| Consumer stuck on one record forever | Poison message: deserialisation or business exception thrown in the poll loop with no handling | Repeating identical error, offset not advancing | Route it to a dead-letter topic. Skipping by resetting the offset loses the record silently |
Producer send() blocks then throws TimeoutException | Buffer exhausted because brokers cannot keep up, or leadership unavailable | buffer.memory, max.block.ms, broker latency, partition leadership | Fix the broker side. Raising buffer.memory buys minutes, not a solution |
| Duplicates downstream | Auto-commit, non-idempotent consumer, or retries without idempotence | Commit strategy; producer enable.idempotence | Commit after processing; make the sink idempotent |
| New consumer processed nothing historical | auto.offset.reset=latest on a group with no committed offsets | Group's committed offsets | Reset to earliest deliberately, with a plan for the replay load |
| Everything slow right after a deploy | Every instance restarted at once: rebalance plus state restore; new client version behaving differently | Rebalance timing versus deploy timeline | Roll deploys; use static membership and persistent state directories |
| Cluster fine, one client slow | Quota throttling; that client's own GC or CPU | Quota config for that client.id; throttle-time metrics | Confirm throttling before blaming the cluster |
Metrics worth alerting on
Broker side (JMX):
| Metric | Meaning | Healthy |
|---|---|---|
UnderReplicatedPartitions | Replicas not caught up | 0, sustained |
OfflinePartitionsCount | Partitions with no leader | 0 always; non-zero is an outage |
ActiveControllerCount | Controllers in the cluster | Exactly 1 across the cluster |
IsrShrinksPerSec / IsrExpandsPerSec | Replication instability | Near zero; repeated cycling is a warning |
RequestHandlerAvgIdlePercent | Spare request-handling capacity | Comfortably above zero; approaching 0 means saturation |
| Produce and fetch request latency (percentiles) | Client-visible broker speed | Stable; watch p99, not the mean |
BytesInPerSec / BytesOutPerSec | Throughput per broker | Balanced across brokers; imbalance suggests skew or leadership concentration |
| Log directory free space | Disk headroom | Trend to full measured in days, not percent |
Producer side: record-error-rate, record-retry-rate, buffer-available-bytes, request-latency-avg. A rising retry rate with stable success is the early warning before buffers fill.
Consumer side: records-lag-max (per partition, not just the group total), fetch-latency-avg, commit-latency-avg, and rebalance frequency. For Streams, add state-restore progress and dropped-late-records.
The two-signal summary from Module 4 still holds: per-partition consumer lag for application health, under-replicated partitions for cluster durability. If you only get two alerts, take those.
Safe rolling upgrade
The principle: one broker at a time, and never proceed while the cluster is degraded.
PREPARE
read the release notes for the exact version jump
confirm RF >= 3 and min.insync.replicas >= 2 on important topics
pin the inter-broker protocol version to the CURRENT version in config
confirm controlled shutdown is enabled
verify under-replicated partitions = 0 before starting
FOR EACH BROKER (one at a time):
┌─────────────────────────────────────────────┐
│ graceful shutdown (lets leadership migrate) │
│ upgrade binaries │
│ start broker │
│ WAIT for under-replicated partitions = 0 │
│ WAIT for it to resume leadership normally │
└─────────────────────────────────────────────┘
only then move to the next broker
FINALISE
second rolling restart to raise the pinned protocol version
watch client error rates for a full traffic cycle before declaring done
Why the protocol version is pinned first: it lets old and new brokers speak a common protocol during the mixed-version window, so you can roll forward — and roll back — safely. Once you raise it, downgrade is no longer available. That is why it is a separate, second pass.
Two more habits: upgrade brokers before clients as a general rule, and never combine a version upgrade with a configuration change. When something misbehaves you want one variable, not two.
Replacing a broker
Two approaches, and the choice depends on whether you keep the data.
Same broker id, data intact (disk survived, host replaced): bring the replacement up with the same broker id and log directory. It rejoins, catches up from the leaders, and no reassignment is needed. This is the cheapest path and the reason broker ids and storage should be stable in your deployment.
New broker id, or data lost: the partitions that lived on the old broker must be moved.
1. Add the new broker to the cluster; confirm it is live
2. Generate a reassignment plan moving the dead broker's replicas
kafka-reassign-partitions.sh --generate
3. Execute it WITH A THROTTLE
kafka-reassign-partitions.sh --execute --throttle <bytes/sec>
4. Verify until complete
kafka-reassign-partitions.sh --verify (also removes the throttle)
5. Rebalance leadership so the new broker takes its share
6. Only now decommission the old broker id
The throttle is the part people skip and regret. Unthrottled reassignment moves data as fast as the disks and network allow, which starves live produce and fetch traffic — you turn a degraded cluster into a slow one. Move partitions in batches rather than the whole cluster at once, and watch produce latency while it runs.
Two related cautions: reassignment is the same tool used for "rebalancing storage", so the same throttling discipline applies; and moving a large partition means copying its entire retained history, so plan the window using the storage arithmetic from earlier in this module.
Practising failure
The uncomfortable truth is that the runbook you have not rehearsed is fiction. Three drills, in order of value:
- Kill one broker in a non-production cluster and watch leader election, client retries, and under-replicated partition recovery. Confirm producers with
acks=allsurvive it. - Force a rebalance storm by setting a low
max.poll.interval.msand observe the signature, so you recognise it later. - Feed a poison message to a consumer and confirm your dead-letter path works before it is needed.
Exercise: At 02:00 a service's lag begins climbing on all 12 partitions of one group. UnderReplicatedPartitions is 0, no deploy occurred, producer throughput is unchanged, and a nightly analytics backfill started at 01:55 reading the same topic from the beginning. Rank the three most likely causes, state the one metric that would distinguish them fastest, and give the action you would take that does not require changing the consumer application.