Skip to content
All writing
Cloud14 Feb 2026·7 min read

A Serverless OCR Pipeline That Handles Bursty Volume

Invoice documents arrive in unpredictable bursts. Notes on building an event-driven extraction pipeline where each stage scales on its own.

  • AWS
  • Lambda
  • SQS
  • OCR
  • Event-Driven

Document processing has an awkward load profile. Nothing happens for hours, then several thousand invoices arrive at once because a partner ran their end-of-day export.

A fixed-capacity service handles that badly in both directions: idle most of the day, overwhelmed exactly when it matters.

Let the upload be the trigger

Making object storage the entry point removes an entire coordination problem. A document lands, an event fires, a function picks it up. There is no poller to tune and no queue depth to babysit at the front of the pipeline.

Decouple every stage

Extraction, validation and persistence have different failure modes and different runtimes. Connecting them through messaging rather than direct calls means a slow validation step queues work instead of dropping it, and a downstream outage doesn't lose documents already extracted.

  • Upload event triggers extraction — no idle capacity
  • Messaging between stages so bursts queue rather than fail
  • Structured validation before anything is accepted as truth
  • Dead-letter handling so unprocessable documents are isolated, not lost

Plan for the documents that will never parse

A meaningful fraction of real-world documents are photographs taken at an angle in poor light. They will not extract cleanly, and a pipeline that retries them forever will eventually consume itself.

Isolating them quickly into a review queue — with the original document attached — is what keeps the automated path fast and the manual path tractable.

Thoughts on this?

Always happy to talk through the engineering trade-offs.

Get In Touch

Related writing