liveBook · Manning

Consumer lag

As explained in Microservices Patterns, Second Edition

The number of events a consumer or view has yet to process.

Consumer lag is the number of events a view has yet to process. In CQRS, it helps monitor the event flow from provider services to query-side views, alongside end-to-end latency. section 13.2.3

A view catching up

After a provider service commits a change, its event may not yet have been processed by the view. A client querying during that delay may see old data; consumer lag measures the view’s unprocessed events. section 13.2.3

Figure 13.4 Because it takes time for an event to flow from the provider service to the CQRS view, a client is not guaranteed to be able to read its own writes. A query might not return data that is up to date.
CQRSViewsAreEventuallyConsistent

See how event-flow delay can leave a CQRS view behind a committed change. section 13.2.3

How Microservices Patterns, Second Edition covers it

How deep it goes
Defines lag as unprocessed events and pairs it with end-to-end latency for monitoring, without giving calculation or alert thresholds.
Examples
Uses a view awaiting provider-service events, where a client may query before the view reflects a committed change.
What it assumes
Assumes provider services publish events that query-side views consume.
What you can do after
Diagnose delayed or stalled view updates by monitoring unprocessed events alongside end-to-end latency.
How it connects
Connects CQRS views and message brokers with event processing, end-to-end latency, replication lag, and eventual consistency.

Also explained in

Compare how 3 books explain consumer lag →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Microservices Patterns, Second Edition. The section links point to the parts of the book it draws on.