DBRaven
Consistency DegradationCritical

CQRS Projection Lag Expansion

In a CQRS architecture, the read-side projection processor falls behind the event stream. The query model serves stale state while the command model has already accepted and committed new writes. As projection lag grows, reads become increasingly inconsistent with writes: violating the eventual consistency promise and exposing users to stale, contradictory, or missing data.

Event store (PostgreSQL/EventStoreDB) + projection processor + read model (PostgreSQL read replica or denormalized store)

Degradation Replay

Stage 1

Nominal: Projection Synchronized

Nominal
Trigger

Projection processor consuming events as fast as they are produced

Operational Metrics
Projection Event Lag
25 events
warn 1,000crit 50,000
Projection Apply Rate
1,100 events/s
warn 600crit 200

Critical: 1,100 exceeds critical threshold of 200 events/s

Stale Read Window
80 ms
warn 2,000crit 10,000
Symptoms
  • ·Projection lag < 50 events: near-real-time read model
  • ·Query-side data consistent with command-side within 500ms
  • ·No failed projection handler events in dead-letter stream
Topology Effects
  • ·Projection processor offset within 1-2 WAL segments or Kafka offsets of writer
  • ·Read model reflects all committed commands
Operational Consequences
  • !Reads consistent with writes within acceptable eventual-consistency window

Operational simulation model only, not a production forecast. Degradation stages are derived from structured operational knowledge, not measured telemetry. Do not use for capacity planning or incident response.

Run With Your Parameters

Adjust the parameters below to see how metric values shift across degradation stages. Formulas are deterministic: same inputs always produce the same output.

Simulation Parameters

Event sourcing projection processing lag behind head

Computed Degradation Stages

nominal·Nominal: Projection Synchronized

Projection processor consuming events as fast as they are produced

Event Write Rate
800events/s
warn: 1,600crit: 2,000
Projection Event Queue
4,000events
warn: 4,000crit: 20,000
Read-Side Staleness
5seconds
warn: 2crit: 6
SLA Breach
10/1
warn: 0.5crit: 0.9
degraded·Lag Onset: Projection Falling Behind

Event apply rate drops below event production rate: lag accumulating

Event Write Rate
1,300events/s
warn: 1,600crit: 2,000
Projection Event Queue
6,500events
warn: 4,000crit: 20,000
Read-Side Staleness
8.12seconds
warn: 2crit: 6
SLA Breach
10/1
warn: 0.5crit: 0.9
warning·Warning: Projection Handler Blocking

A failing event handler blocks the projection stream: lag rate accelerating

Event Write Rate
1,700events/s
warn: 1,600crit: 2,000
Projection Event Queue
8,500events
warn: 4,000crit: 20,000
Read-Side Staleness
10.62seconds
warn: 2crit: 6
SLA Breach
10/1
warn: 0.5crit: 0.9
critical·Critical: Projection Rebuild Required

Projection lag so large that incremental catch-up is infeasible: full rebuild needed

Event Write Rate
2,200events/s
warn: 1,600crit: 2,000
Projection Event Queue
11,000events
warn: 4,000crit: 20,000
Read-Side Staleness
13.75seconds
warn: 2crit: 6
SLA Breach
10/1
warn: 0.5crit: 0.9
recovery·Recovery: Projection Rebuilding

Projection rebuild initiated; processor replaying events from last known-good checkpoint

Event Write Rate
1,000events/s
warn: 1,600crit: 2,000
Projection Event Queue
5,000events
warn: 4,000crit: 20,000
Read-Side Staleness
1.88seconds
warn: 2crit: 6
SLA Breach
00/1
warn: 0.5crit: 0.9

Threshold Events

Read Staleness Exceeds SLAwarning

Projection lag at 5.0s exceeds acceptable staleness SLA of 2.0s. Read-side views are serving stale data.

threshold: 2actual: 5
Read Staleness Exceeds SLAcritical

Projection lag at 8.1s exceeds acceptable staleness SLA of 2.0s. Read-side views are serving stale data.

threshold: 2actual: 8.12

Interpretation

critical

CQRS projection lag of 5s creates 13.8s staleness at 2,000 write RPS: 6.9× SLA.

Bottleneck

Projection processor cannot keep pace with write rate: read side falls behind

Recommendation

Scale projection consumers horizontally. Add projection position metrics to alert before SLA breach. For strongly-consistent reads, route to command side (primary) and accept latency cost.

Parameterized simulation: not a production forecast. Values derived from deterministic formulas applied to your parameters. Do not use for capacity planning or operational decisions without validation.

Propagation Model

Linear
Event StreamProjection Processor, Read Model

Projection lag accumulates at (event_rate - projection_apply_rate) events/sec; read model falls behind committed event log

Stabilizes: Lag stabilizes when projection apply rate recovers above event rate

Thresholdmild amplification
Projection LagRead API, UI Query Layer

Read queries return state that contradicts recent command results; users who just wrote data see pre-write state on next read

Stabilizes: Stale read window closes as projection catches up to command model LSN

Feedback Loopmoderate amplification
Failed Projection HandlerEvent Processing, Retry Queue

A failed event handler blocks the projection processor; all subsequent events queue behind the failing event until handler is fixed or event is skipped

Stabilizes: Unblocked only by fixing the handler or explicitly skipping the failing event

Recovery Patterns

Fix handler and resume from blocked offset

15-120 minutes depending on backlog accumulated during block
Tradeoffs
  • ·Handler fix requires code deployment: adds deployment risk during incident
  • ·If skipping the bad event, manual reconciliation needed for affected entities
Residual Risks
  • !Skipped events leave permanent gaps in read model: audit trail incomplete

Full projection rebuild from event store

30 minutes to 6 hours depending on event store depth
Tradeoffs
  • ·During rebuild, read model unavailable or frozen: user-facing features degraded
  • ·Event store under significant read load during replay: monitor primary DB
Residual Risks
  • !If event store does not retain all events, rebuild cannot recover to full state

Operational Summary

CQRS projection lag occurs when the read-side projection processor cannot keep up with the event stream. The critical failure mode is a blocking event handler: a single failing event blocks all subsequent events, causing the read model to freeze while the command model continues accepting writes. The divergence grows with every write until the handler is fixed or the event is skipped. Prevention requires handler circuit breakers, explicit event schema versioning, and projection lag monitoring with rate-of-change alerting.

CQRS Projection Lag Expansion: DBRaven