← Blog

Kafka · Consumer Lag · Backpressure

What Does Rising Kafka Consumer Lag Actually Mean—and Why Can Adding Consumers Make It Worse?

Consumer lag tells you how far behind a Kafka consumer group is, not why. This article walks through the usual causes (rate mismatch, hot partitions, slow dependencies, rebalances, poison records) and how to tell them apart before scaling.

Aashaya Aryal

January 8, 2025 · 15 min read

Updated November 17, 2026

Close-up of an analytics dashboard displaying metric cards, line charts, a CTR percentage, and a quality score.

A Kafka alert fires: consumer lag is at 1,000,000. The natural first move is to add consumers.

Sometimes that's exactly right. Sometimes it changes nothing. And sometimes it makes the incident worse, either by putting more pressure on a struggling database or by pushing the consumer group through repeated rebalances.

The reason is that consumer lag is a symptom, not a diagnosis. The same rising number can come from more incoming traffic, a slower database, one hot partition, a group that keeps rebalancing, records that suddenly take longer to process, or a single bad event blocking a partition. Each of those needs a different response.

Kafka's consumer model makes the distinction matter. A topic is split into partitions, and within a consumer group each partition is read by exactly one consumer at a time (the Kafka design docs describe this). So adding consumers only adds useful parallelism while there are partitions left to hand out, and only while everything downstream has room for more work.

The question I find most useful isn't "how high is lag?" but "why is work arriving faster than finished work is leaving?" Once lag is treated as a throughput problem rather than one scary number, incidents get much easier to reason about.

What consumer lag measures

A Kafka partition is an ordered log, and every record has an offset (its position in that log). If the newest record in a partition is at offset 901 and the consumer group has committed up to offset 701, lag for that partition is about 200 records.

Diagram

offset 1

...

offset 701
Consumer position

702

...

901
Log end

Lag = unprocessed distance

Amazon MSK's documentation on consumer lag describes it the same way: the distance between the latest data and how far the consumer has got. MSK reports a few versions of it, including total offset lag, maximum offset lag across partitions, and estimated time lag.

That number tells you how far behind the group is. It doesn't tell you why. A million records of lag could be a harmless burst that's already draining, a consumer group that's permanently too small, one problem partition, or a downstream system that just got 20 times slower.

Lag is a rate problem

Two rates explain most of what lag does: the arrival rate (records produced per second, often written λ) and the processing rate (records finished per second, μ). The backlog changes at roughly arrival rate minus processing rate.

  • If consumers process 12,000/sec while producers write 10,000/sec, the backlog shrinks.
  • If both run at 10,000/sec, it stays where it is.
  • If producers outpace consumers, it grows.

That's why the same lag value can describe very different situations. Here are three consumer groups, each reporting 1,000,000 records of lag:

SystemArrivalProcessingWhat's happening
A8,000/s12,000/sRecovering at 4,000/s; drains in about 250 seconds
B10,000/s10,000/sKeeping up with new traffic but never catching up
C12,000/s8,000/sFalling behind by 4,000/s; another 1.2 million records in five minutes

So I'd always want the direction next to the size. Lag of 1,000,000 with a change of −4,000/sec tells me "behind, but recovering". Lag of 20,000 with a change of +5,000/sec may deserve more attention: the number is smaller but the trend is worse.

Time behind can matter more than records behind

Say one topic has 500,000 records of lag, but producers write 1,000,000 records per second. That backlog is less than a second of work. Another topic has only 5,000 records of lag, but the oldest unprocessed event has been waiting 45 minutes. For most applications, the second one is in far worse shape.

Offset lag tells you how many records separate the consumer from the end of the log. Event age (or MSK's estimated time lag) tells you how stale the processing has become. For anything user-facing I want both, because the real requirement usually sounds like "process each event within 30 seconds", not "keep the offset gap under 50,000". Lag is easier to act on when it's expressed in the unit the business cares about, which is time.

More consumers only help up to the partition count

Take a topic with 12 partitions and a group of 4 consumers. Each consumer gets about 3 partitions. Scale to 12 consumers and each gets one, which is great if each partition has enough work. Scale to 20 and several consumers have nothing to read.

Diagram

Partition 1

Partition 2

Partition 3

Partition 4

Consumer 1

Consumer 2

Consumer 3

Consumer 4

Consumer 5
Idle

Consumer 6
Idle

The useful number of consumers in a group is at most the number of partitions. Past that point, extra replicas add cost, connections, deployment complexity and membership churn without processing any more records. "Lag is high, add replicas" isn't a complete scaling strategy, because the partition count puts a ceiling on how much parallelism the group can use.

Hot partitions

Even with one consumer per partition, work isn't necessarily spread evenly. Twelve partitions and twelve consumers sounds ideal until you see the traffic: partitions 0 to 10 each get around 100 records/sec, and partition 11 gets 8,000.

Diagram

Partition 11
8,000 msg/s

Partition 1
100 msg/s

Partition 2
110 msg/s

Consumer A
HOT

Consumer B

Consumer C

The group reports a large total lag while most consumers sit nearly idle. Adding consumers does nothing, because partition 11 still belongs to one of them. This is why lag per partition is far more useful than total group lag.

Hot partitions usually start with the partition key (the value Kafka hashes to choose a partition). If events are keyed by customerId, and most customers send 100 events an hour while one sends 5,000,000, all of that customer's events land in the same partition. Kafka is doing exactly what the key asked.

The fixes are choosing a better-distributed key, splitting extremely hot identities, or narrowing how much needs strict ordering. All of them change semantics. If every event for a customer has to be processed in order, spreading that customer across partitions can break the guarantee the key was chosen for. In Kafka, throughput and ordering are linked: changing one can change the other.

When the bottleneck is downstream

Here's a consumer that reads a record, deserializes and validates it, then inserts it into PostgreSQL. Lag starts rising. Consumer CPU is at 27%, memory is fine, pods are healthy. Scaling from 10 consumers to 30 seems reasonable.

But all 30 now write to the same database. Connections go up, database CPU goes up, lock contention rises, query latency gets worse, and each record takes longer to finish.

Diagram

Lag Rising

Add Consumers

More Concurrent DB Writes

Database Saturates

Each Record Takes Longer

Lag Rises Faster

The consumers were never the limit. The database was. Scaling consumers has to account for the whole processing path, not just Kafka.

The same thing happens with an HTTP dependency. If per-record processing normally takes 20 ms and a downstream API slows to 500 ms, Kafka is fine, the consumers are fine, nothing crashes, and yet each instance now finishes a fraction of its old throughput. Lag rises. The right fix is often to repair or protect the dependency. Adding consumers just sends more simultaneous calls to a service that's already struggling. More concurrency helps only while there's spare capacity downstream; after that it creates contention.

Slow processing can trigger rebalances

Consumers fetch records by calling poll() in a loop. The setting max.poll.interval.ms (see the consumer configuration reference) is the longest a consumer may go between polls before the group treats it as failed and reassigns its partitions. This is called a rebalance: the group redistributes partitions among its members.

Now suppose max.poll.records is 500 and each record suddenly takes 800 ms to process, one at a time. A full batch takes 500 × 0.8 s = 400 seconds. If max.poll.interval.ms is 300 seconds, the consumer is busy doing useful work, but from the group's point of view it has stopped polling. Its partitions get reassigned, processing pauses or moves, and lag rises further.

To group coordination, "crashed" and "alive but slow between polls" can look the same. So max.poll.records, max.poll.interval.ms and real per-record processing time have to be considered together. Options include smaller batches, speeding up the slow operation, or restructuring so polling isn't blocked by long work. Raising the timeout indefinitely has a cost too: a consumer that's genuinely stuck takes longer to detect.

Scaling and deployments cause rebalances too

Partitions are redistributed whenever group membership changes: a consumer joins, leaves or crashes, a deployment replaces pods, or an autoscaler changes the replica count. With the classic rebalance protocol, those changes can pause processing while assignments are worked out. That means scaling can increase lag during the very action meant to reduce it.

This can turn into a feedback loop with lag-based autoscaling (for example KEDA's Kafka scaler). Say the scaler sees 200k of lag with 4 consumers and adds 4 more. They join, the group rebalances, processing slows, and lag climbs to 300k. The scaler sees lag getting worse and adds more consumers, which causes another rebalance.

Diagram

Lag High

Autoscaler Adds Consumers

Consumer Group Rebalances

Processing Temporarily Slows

Lag Rises

Autoscaler Adds More

Stabilization windows on the autoscaler and extra signals such as the arrival rate help break that loop. New capacity isn't instant; it has a transition cost.

Kafka 4.0 made the newer consumer rebalance protocol from KIP-848 generally available. It moves assignment to the broker and rebalances incrementally instead of stopping the whole group, which reduces disruption. It doesn't make scaling free: a new consumer still has to start up, receive partitions, warm its caches, JVM and connections, and the group still can't go beyond the partition count or what downstream systems can absorb.

Deployments deserve the same attention. Rolling out 20 consumer pods means repeatedly changing group membership: a pod leaves (rebalance), its replacement joins (rebalance), the next pod leaves, and so on. Depending on the protocol and assignment strategy, a rollout can spend a surprising amount of time moving partitions instead of processing records. Amazon MSK's client best practices recommend clean shutdown, static membership where it fits, and the sticky or cooperative-sticky assignors to cut down unnecessary movement.

Poison records

A poison record is one that fails every time it's processed. Suppose partition 4 has offsets 1001 and 1002 processed, 1003 malformed, and 1004 onward valid. The consumer reaches 1003, processing fails, and the retry policy is "retry forever". The partition stops moving.

Diagram

blocks progress

1001
processed

1002
processed

1003
fails repeatedly

1004

1005

1006

Kafka is up, the consumer is up, CPU may even be low, and lag for that partition grows without limit. More consumers can't help, because the bad record is stuck inside one ordered partition. The system needs an explicit policy for records like this.

A common one is a dead-letter topic: try the record a few times, then move it aside to a separate topic and continue. That restores progress, but it also means offset 1004 gets processed while 1003 is unresolved elsewhere. For independent events that's fine. For a strict sequence, like version 7 and version 8 of a balance change, applying 8 without 7 may be wrong. A dead-letter policy is a business decision about ordering, not just a Kafka setting.

Retries can also eat the capacity needed for recovery. If a dependency fails for every record, each one goes through five attempts while new records keep arriving. Useful throughput drops toward zero while the arrival rate stays the same. A retry policy that seems safe for one message can become a backlog generator across a whole stream. Bounded attempts, backoff and explicit failure handling matter here for the same reasons they do in synchronous systems.

Large backlogs and stale work

Kafka is good at holding a durable backlog, but that doesn't make every backlog harmless. If lag is 2,000,000,000 records and the group has 5,000 records/sec of spare capacity after keeping up with new traffic, draining takes 400,000 seconds, or more than 4.6 days. The group is technically recovering, but the business may not be able to wait four days. A queue buys time; it doesn't create processing capacity. The Amazon Builders' Library article on avoiding insurmountable queue backlogs covers this well.

Large backlogs also raise the question of whether all of it is still worth processing. A temperature reading from eight hours ago might still matter for historical analytics but be useless for live alerting. A "user started typing" event from eight hours ago probably means nothing. Depending on what the events mean, recovery can include dropping stale work, merging events that newer ones replace, processing newer work first, or separating critical streams from the rest.

That last option matters before an incident, too. If one consumer pool handles payments, marketing analytics, email opens and recommendation refreshes, then during overload the analytics work competes with payments for the same CPU, connections and API quota. Splitting them gives each its own lag, alerts, scaling and recovery priority:

Diagram

Kafka

Critical Consumer Pool

Background Consumer Pool

Payments

Analytics / Refresh

A single total-lag number often hides the thing operations most needs to know: which business work is late.

What to put on the dashboard

A total lag of 1,000,000 could be 100 partitions with 10,000 each, which suggests the group is broadly short on capacity. Or it could be 99 partitions at zero and one partition at 1,000,000, which points at something local: a hot partition, a poison record, a slow record type, or a bad key. A per-partition view makes that obvious:

PartitionLagInput rateProcess rateOldest age
0200500/s510/s0.4 s
1170480/s500/s0.3 s
2850,0007,000/s2,000/s14 min
3110450/s470/s0.2 s

Partition 2 is the incident; the total is just a summary.

Beyond Kafka itself, a useful dashboard connects lag to what the consumers and their dependencies are doing:

AreaWhat to show
KafkaLag per partition, oldest message age, arrival rate, group state, rebalance rate
ConsumersRecords/sec, batch processing time, time between polls, errors, retries, CPU, memory
DownstreamDatabase latency, connection pool usage, HTTP dependency latency, 429s, 5xx, timeouts
AutoscalingDesired and actual consumer count, recent scaling events, startup time

The goal is to answer "where did useful throughput go?", not just "how far behind are we?"

Two details are easy to miss. First, MSK only emits lag metrics while a group is in a STABLE or EMPTY state. During rebalancing, lag data points can simply disappear, so a gap in the lag series must not be read as zero lag. If the group keeps rebalancing, the missing data is part of the incident; watch group state, rebalance frequency and membership alongside lag. Second, rebalance rate belongs next to lag. Lag rising together with rebalances and an oscillating consumer count points at group instability. Lag rising with steady rebalances and rising database latency points downstream.

Autoscaling and drain time

CPU-based autoscaling can miss queue pressure entirely. A consumer waiting on database connections, an HTTP dependency, disk or a rate-limited provider may show 25% CPU while lag climbs. That's why queue consumers often scale on lag. But lag alone isn't enough either. Good scaling decisions also consider arrival rate, processing rate, partition count and downstream capacity, and they check whether the last scaling action actually helped.

For example, with arrival at 10k/s, processing at 8k/s and 1M lag, adding consumers lifts processing to 14k/s. The group now has 4k/s of recovery capacity, and scaling again probably isn't needed. If the same scale-out only moved processing to 8.5k/s, the fleet got much bigger and throughput barely changed. That's strong evidence that consumer compute wasn't the bottleneck, and the autoscaler should stop adding instances to a problem it can't fix.

When processing is faster than arrival, you can estimate how long recovery will take:

With 5,000,000 lag, 20,000/s arriving and 25,000/s processed, there's 5,000/s of spare capacity, so draining takes about 1,000 seconds, or roughly 17 minutes. That's something an operator can decide on: if 17 minutes is fine, let it recover; if not, add safe capacity or reduce incoming work. It's far more useful than a red lag alarm.

If processing is slower than arrival, there's no finite drain time. The backlog is growing, and the dashboard should make that obvious:

MetricValue
Lag5.0M
Oldest event18 min
Arrival rate20k/s
Processing rate17k/s
Backlog growth+3k/s
Estimated drain time∞

A decision tree for lag incidents

When lag starts rising, this is roughly how I'd work through it:

Diagram

No

Yes

Yes

No

Yes

No

Yes

Consumer Lag Rising

Most partitions affected?

One / few partitions

Most partitions

Consumers CPU-bound?

Increase safe compute
or optimize work

Downstream latency rising?

Fix or protect dependency

Rebalances frequent?

Stabilize group / autoscaling

Inspect hot key,
poison record,
partition skew

It isn't exhaustive, but it puts the right question first: is the lag broad or localized? Then: is useful work limited by the consumers themselves, the downstream path, group coordination, or the partitioning?

Adding partitions

Suppose a topic has 12 partitions and 12 consumers, all saturated, downstream systems still have headroom, and arrival is still above processing. Now the partition count really is the ceiling, and adding partitions can unlock more parallelism.

Partitions cost more than they look, though. They affect broker metadata, open files, replication, consumer assignment, ordering and key distribution. Adding partitions also doesn't move existing records: new records may hash to different partitions, but the backlog stays where it is. Partition count is best treated as capacity planning, not an emergency lever.

When lag should page someone

Queues exist so producers and consumers don't have to match each other's throughput moment to moment. If traffic spikes to 10 times normal for 30 seconds, consumers fall behind, Kafka absorbs the burst, and the backlog drains afterwards. That's the system working as designed. Paging whenever lag is above zero defeats much of the point of having a queue.

A better question is whether lag is outside its normal range and whether the group can recover within the business deadline. Alerts can say that directly:

  • oldest event age above 5 minutes and lag still growing
  • estimated drain time above 30 minutes
  • one partition holding more than 70% of the group's lag
  • rebalance rate abnormally high

Those describe failure modes. A static threshold like "lag above 100,000" mostly describes volume.

Key takeaways

  • Read lag together with its direction: arrival rate, processing rate, and whether the backlog is growing, stable or draining.
  • Track the age of the oldest unprocessed event, not just the record count. Requirements are usually about time.
  • Look at lag per partition. A hot key or poison record shows up as one partition far behind the rest.
  • Consumers beyond the partition count sit idle, and consumers beyond what downstream systems can absorb make things worse.
  • Keep batch processing time comfortably inside max.poll.interval.ms, and watch rebalance rate next to lag. A gap in MSK lag metrics can mean the group is unstable, not that lag is zero.
  • Give poison records an explicit policy, and decide deliberately what ordering you give up with a dead-letter topic.
  • Estimate drain time and alert on age, growth and skew rather than a fixed lag threshold.

References