DBRaven
Failure Mode · capacity

Queue Backlog Accumulation

critical

Summary

Message queue or event stream consumer processing rate falls below producer write rate, causing consumer lag to grow unboundedly: eventually leading to increased end-to-end latency, producer backpressure, data expiry, or queue resource exhaustion.

Description

A queue or event stream reaches a dangerous state when the rate at which messages are produced exceeds the rate at which consumers can process them. Consumer lag: the number of messages that have been produced but not yet processed: begins to grow. Initially this is a latency problem: messages sit in the queue longer before processing. As lag grows, it becomes a capacity and reliability problem.

In Kafka, each consumer group maintains an offset per partition. Consumer lag (measured in bytes or message count behind the latest offset) grows when processing is slow. Kafka retains messages on disk regardless of consumer progress, but retention is bounded by time (log.retention.hours) or size (log.retention.bytes). If lag grows faster than the retention window allows, offsets fall off the beginning of the log : the consumer has "fallen off the retention window" and loses messages permanently. At default retention of 7 days and a lag growth rate of 1 hour per day, the consumer will fall off the window in 7 days.

In RabbitMQ, the queue accumulates messages in memory, then pages to disk when memory threshold (vm_memory_high_watermark, default 40% of RAM) is crossed. A large backlog can fill all available disk space, causing the broker to block all producers with connection.blocked until disk space is reclaimed.

Root causes split into two categories: consumer-side slowdowns (a downstream database or API that the consumer calls becomes slow, increasing per-message processing time) and producer-side spikes (a burst of user activity, a batch job, or a viral event that temporarily exceeds the consumer's sustained capacity).

Processing time spikes are the most common trigger: if the consumer calls PostgreSQL for each message and PostgreSQL p99 increases from 5ms to 500ms due to lock contention, throughput drops from 200 msg/s to 2 msg/s: a 100x reduction: and lag grows at the producer's full rate.

Characteristics

Propagationlinear
Time to detectSeconds with consumer group lag monitoring and rate-of-change alerting. Without active lag monitoring: minutes to hours, depending on whether SLA violations on downstream systems are the first signal. By the time a user- facing SLA violation is observed, lag may have been growing for 30+ minutes.
Blast radiusGrowing lag increases end-to-end latency for all data flowing through the queue: downstream systems receive events that happened minutes or hours ago. In event-driven architectures where downstream projections, notifications, or billing records are built from the queue, staleness propagates through all downstream systems. In the worst case (retention expiry), permanently lost messages produce silent data gaps in all downstream systems built from that queue.

Triggers

  • ·Downstream database or API slowdown increasing per-message processing time
  • ·Producer throughput spike (campaign, viral event, batch import) exceeding sustained consumer capacity
  • ·Consumer instance failure or deployment restart reducing consumer count
  • ·Consumer logic regression increasing per-message processing time (new code path, N+1 query)
  • ·Kafka consumer group rebalance reducing effective consumer count during rebalance window

Detection Signals

queue depthalertlatency spikeerror rate spikelog errors

Mitigation Strategies

Scale consumer instances to match producer throughputcomplexity: low

Add consumer instances (up to the partition count for Kafka consumers). For Kafka, one consumer per partition is the maximum parallelism; if all partitions are consumed and lag still grows, partition count must increase or per-message processing time must decrease. For RabbitMQ, consumers can scale beyond queue count.

Identify and fix slow downstream dependenciespreventscomplexity: medium

Instrument consumer processing time by stage. If the bottleneck is a database call, add a connection pool, fix a missing index, or batch the reads. If it is an external API, add a circuit breaker and process API-failure messages asynchronously with a dead-letter queue.

Implement producer rate limiting when consumer lag exceeds thresholdcomplexity: high

Monitor consumer lag and apply backpressure to producers when lag exceeds a safe threshold. Producers throttle their write rate or shed non-critical messages. This prevents lag from growing to retention expiry.

Configure Kafka retention to exceed maximum expected lag recovery timecomplexity: low

If a consumer falls behind, it must be able to catch up before retention expires. Set retention.ms to at least 3× the expected maximum lag duration. For a consumer that may fall behind by 24 hours, set retention to 72+ hours.

Implement dead-letter queue for persistently failing messagescomplexity: medium

Messages that fail processing repeatedly (poison pills) block queue progress. Route messages that fail 3+ times to a dead-letter queue for manual inspection and replay, preventing them from blocking the backlog from draining.

Recovery Steps

  1. 1.Measure current lag and rate of change: is lag growing, stable, or shrinking?
  2. 2.Identify root cause: producer spike vs. consumer slowdown (compare produce rate vs. consume rate)
  3. 3.If consumer slowdown: identify the slow stage via per-stage latency metrics and fix the bottleneck
  4. 4.Scale consumer instances up to partition count to maximise parallelism
  5. 5.If lag is within retention window: let consumers drain naturally after root cause is fixed
  6. 6.If lag has exceeded retention window: identify which offsets are lost and assess data gap impact

Estimated recovery time: Time to drain depends on consumer throughput headroom above producer rate. If consumer capacity is 2× producer rate, a 24-hour lag drains in 24 hours. Root cause fix + scale-up can reduce drain time to hours. Permanent data loss from retention expiry requires separate assessment and reconciliation.

Affected Systems

Patterns

event sourcingcqrsoutbox patternsaga patterncompeting consumersbackpressure

Technologies

kafkarabbitmqelasticsearch

Basis

Core operational challenge in event-driven architectures with precise metrics (consumer lag) and well-understood failure modes; retention expiry data loss is a real and well-documented consequence

Run This Failure

Blast radius analysis for this failure mode within each scenario that carries it.

Related Architecture Knowledge

Inbound: affects this entity

MitigatesPattern
backpressure
Grounded

Backpressure prevents queue backlog accumulation by signaling producers to slow or pause ingestion when the consumer is approaching capacity, ensuring the queue depth stays bounded rather than growing without limit.

Tradeoffs

  • ·Backpressure reduces throughput at the producer during capacity pressure; some use cases require drop instead of block
Full relationship →
Vulnerable ToWorkload
event streaming workload
Grounded

Event streaming workloads produce events faster than consumers can process them during spikes, accumulating a consumer group lag that grows unboundedly if consumer throughput cannot recover to exceed producer throughput.

Tradeoffs

  • ·Kafka retains events by time or size: a slow consumer cannot force Kafka to slow down producers
  • ·Adding consumer group members beyond partition count does not help: extra consumers sit idle
  • ·Exactly-once processing (Kafka transactions) reduces max consumer throughput by ~30% vs at-least-once
Full relationship →
Introduces RiskFailure Mode
slow consumer
Grounded

A slow consumer processing messages below the producer rate causes queue backlog to accumulate. If processing speed does not recover, backlog grows unboundedly, eventually causing either message loss (if the queue has a depth limit) or indefinite processing delay.

Tradeoffs

  • ·Increasing consumer parallelism helps only up to the partition count (Kafka) or queue message visibility limit (SQS)
  • ·Speeding up per-message processing (optimization) has a multiplicative effect on throughput recovery
  • ·Backlog recovery after a slow consumer incident may require priority processing of newest messages first
Full relationship →

Used In Architecture Scenarios

Analytics Data Platformhigh

Analytics Pipeline

An OLAP-oriented analytics architecture that ingests operational changes from PostgreSQL via WAL-based CDC into Kafka, then routes them to a columnar analytics store (ClickHouse or Snowflake) for product analytics, business intelligence, and operational reporting. The CQRS separation ensures analytical queries never degrade transactional write performance, and materialized views provide pre-aggregated query acceleration for the most expensive analytical patterns.

Developer Tools Platformhigh

Multi-Tenant SaaS

A multi-tenant developer tooling platform providing CI/CD pipeline execution, log aggregation, code analysis, and dependency scanning across isolated tenant organizations. Tenant isolation is the primary correctness constraint: a security boundary violation between tenants is a critical incident, not a performance event. PostgreSQL row-level security enforces data isolation; Redis manages job queues and distributed locks; Elasticsearch indexes pipeline log output for search; Kafka delivers webhook events to tenant-registered endpoints; MinIO stores pipeline artifacts. Resource quota enforcement prevents any single tenant's burst from affecting others.

Distributed Job Queue Platformmoderate

Write-Heavy Application

A durable background job execution platform where jobs are enqueued via API and executed by competing consumer worker pools. PostgreSQL is the durable job store, job definitions, retry state, scheduling metadata, and dead-letter records persist in PostgreSQL with ACID guarantees, surviving any worker or queue infrastructure failure. Redis tracks in-flight job state (which worker claimed which job, visibility timeout lease expiry) to enable fast lease checks without PostgreSQL queries on the hot path. Temporal provides workflow orchestration for multi-step jobs that require coordination across multiple execution stages, with built-in state machine semantics and durable activity execution. Kafka carries job completion events to downstream consumers (analytics, billing triggers, notification fan-out). Backpressure between the job enqueue rate and worker execution rate prevents runaway job accumulation when workers are degraded.

E-Commerce Order Platformhigh

Marketplace Platform

An e-commerce order lifecycle platform handling cart, checkout, payment, fulfillment, and returns across a mixed read/write workload where product discovery is read-heavy, checkout is write-transactional, and fulfillment is event-driven. The saga pattern orchestrates multi-step checkout: reserve inventory → charge payment → confirm order → notify fulfillment. PostgreSQL owns order records and inventory with row-level locking; Redis holds session state and cart contents with sub-millisecond access; RabbitMQ delivers fulfillment notifications with dead-letter handling; Elasticsearch serves product search and order history with faceted navigation. CQRS separates the write command path from the read model: the order read model is denormalized for fast order history queries without joining across domain tables.

IoT Telemetry Ingestion Platformhigh

Write-Heavy Application

A high-rate device telemetry ingestion architecture designed for millions of devices emitting metrics at 1–60 second intervals. Kafka absorbs device writes as an ingestion buffer, decoupling device-facing ingest endpoints from the storage write path so that downstream storage pressure never propagates back to devices. TimescaleDB provides time-series storage with automatic chunk partitioning by time range, native compression, and continuous aggregate views for rollup queries. ClickHouse serves as the OLAP layer for device fleet analytics queries. Redis caches last-known device state (current readings per device) for real-time alerting queries that must not scan historical storage. Backpressure on the Kafka consumer side prevents storage write throughput from being overwhelmed by burst ingestion events from device reconnect storms.

Notification Delivery Platformmoderate

Event-Driven System

A multi-channel notification delivery architecture that accepts upstream business events (order placed, payment received, comment posted, threshold alert triggered) and routes them to per-channel delivery workers (push via FCM/APNs, email via SendGrid, SMS via Twilio, in-app via WebSocket). Kafka carries raw business events from upstream producers. RabbitMQ handles per-channel fan-out with separate exchanges and queues per delivery channel, isolating email queue backlog from push notification delivery. PostgreSQL provides durable notification state tracking (sent, failed, bounced, suppressed). Redis enforces per-user rate limiting (notification frequency caps to prevent fatigue) and stores deduplication tokens to prevent duplicate sends across retry attempts. The inbox pattern on the consumer side ensures idempotent delivery even when Kafka produces duplicate events.

Social Feed Platformhigh

Event-Driven System

A social activity feed architecture where user actions (posts, likes, comments, follows) fan out asynchronously to follower timelines. Redis stores hot feed data as pre-materialized lists per user, enabling O(1) timeline reads for the 99th percentile of users. Kafka carries fan-out work to async workers that write to follower Redis keys. PostgreSQL is the durable store for the social graph, posts, and user content. The system uses a hybrid fan-out model: fan-out-on-write for users with fewer than ~10,000 followers (low fan-out cost), fan-out-on-read for high-follower celebrity accounts where pre-materialized fan-out would saturate workers and Redis write bandwidth.

Streaming Media Platformhigh

Event-Driven System

A video and audio streaming architecture where content ingestion triggers an async multi-variant transcoding pipeline, CDN delivery handles 95%+ of playback traffic, and Cassandra absorbs the write volume of per-user viewing history. Kafka decouples upload events from transcoding workers; MinIO stores raw and encoded assets; Redis maintains playback session state and view counters. The architecture must handle upload spikes without blocking delivery, and cache cold starts without cascading database load.

Two-Sided Marketplace Platformexpert

Marketplace Platform

A two-sided marketplace architecture serving buyers, sellers, listings, transactions, search, and notifications from a shared infrastructure, where multiple independent domains must coordinate without tight coupling. Event sourcing captures every state transition; the saga pattern orchestrates multi-step transactions (create order, reserve inventory, charge payment, notify seller) with compensating transactions for partial failures. Kafka decouples domain event publication from consumption; RabbitMQ handles notification fanout; Elasticsearch serves listing search; Redis caches listing display and session state.