Back to Blog
Published:
Last Updated:
Fresh Content
Legal AI in the ERPChapter 11

FIFO or standard queue for parallel AI work?

7 min read
1,511 words
high priority
Ali Ahmed

Ali Ahmed

AI Solutions Engineer, Cognilium AI

TL;DR

FIFO where order is the correctness requirement, standard where throughput is. A document pipeline usually needs both, at different stages.

FIFO where order is a correctness requirement. Standard where throughput is. In a document-processing pipeline that usually means both — and the interesting decision is where you put the boundary.

Choosing one for the whole system is the common mistake, and it costs you either correctness or the parallelism that made the design worth building.

What is the difference that actually matters?

Not the feature list. The constraint each one imposes on you.

A FIFO queue guarantees order and exactly-once processing within a message group. That guarantee has a price: messages in the same group are processed one at a time. If everything shares a group, you have built a serial system with a queue in front of it.

A standard queue makes no ordering promise and can deliver a message more than once. In exchange it scales out as wide as you can consume it.

So the question is never "which is better". It is: for this specific hop, is the order of messages part of being correct — or just how they happened to arrive?

Where does FIFO earn its cost?

Between stages, where one thing must finish before the next begins.

In a contract-review pipeline the playbook has to be processed before any contract can be measured against it. That is not a preference; measuring against rules that do not exist yet produces nothing. A stage boundary with a real dependency is exactly what FIFO is for.

Two things make it the right call there:

  • The volume is low. One playbook, one contract — a handful of messages, not thousands. You are paying for ordering with throughput you were not going to use.
  • Duplicate delivery would be expensive. Reprocessing an entire playbook or a whole contract is minutes of work and a pile of model calls. Exactly-once is worth having.

This is the shape we use — FIFO on the hops between stages, where each message represents one whole document moving forward.

Where does standard win, decisively?

Inside the stage that fans out — and this is where the throughput lives.

Once a contract is split into chunks, each chunk is independent. Chunk forty does not depend on chunk three. They can be scored in any order, and the faster they all finish the better.

Put those on a FIFO queue with a shared group and you have serialised the one part of the system that was supposed to run wide. The queue choice, not the model, becomes your runtime.

So the fan-out queue is deliberately standard: many workers pull chunks concurrently across multiple tasks, order is irrelevant because the results are reassembled by identifier, and the stage finishes when the last chunk does rather than when a sequence completes.

That single choice is the difference between a review that finishes in minutes and one that finishes in an hour. It is also invisible in any feature comparison, which is why it belongs in an architecture conversation rather than a procurement one.

What about the duplicates standard queues allow?

You design for them, and it is easier than the ordering problem you avoided.

A standard queue can deliver the same message twice. In a fan-out stage that means the same chunk might be scored twice. Three habits make that a non-event:

  • Make the work idempotent. Write results keyed by chunk identifier. Processing the same chunk twice produces the same row, not two rows.
  • Set the visibility timeout longer than the slowest realistic run. Most duplicate deliveries are not duplicates at all — they are the queue correctly redelivering work it believed had failed because the worker was still busy.
  • Let the dead-letter queue be generous on a fan-out stage. One poisoned chunk should not fail a document; it should be isolated and reported while the rest completes.

Idempotent writes are the whole trick. Once results are keyed rather than appended, at-least-once delivery stops being a correctness question and becomes a cost question.

What does this cost you if you get it wrong?

Both mistakes are recoverable, and they fail in opposite directions — which is why the diagnosis matters more than the fix.

FIFO where you needed standard looks like a performance problem that no amount of scaling solves. You add workers and nothing gets faster, because the queue is handing work out one message at a time within the group. Teams usually blame the model, then the container, then the network — and the answer was in the queue configuration the whole time.

Standard where you needed FIFO looks worse and shows up later. Work completes out of order, and most of the time that is harmless — until the run where a downstream stage starts before its input exists. It is intermittent, which is the hardest kind of defect to chase.

The tell that distinguishes them: if adding capacity changes nothing, suspect ordering. If failures are rare and unreproducible, suspect the missing dependency.

This is the shape Paralegent AI runs — FIFO between stages, standard inside the fan-out. It is Cognilium's contract-review app in its family of AI optimization apps for Microsoft Dynamics 365, and the same split applies to any one of them we build with a document fan-out in it.

So how do you decide?

One question per hop, and it is not about the queue at all:

If two of these messages were processed out of order, would the result be wrong — or just different?
  • Wrong → FIFO. A dependency exists. Pay the throughput cost.
  • Just different → standard, with idempotent writes and a visibility timeout matched to your slowest unit of work.

And decide it per hop, not per system. The pipeline that gets this right usually has FIFO between stages and standard inside them, because those two hops are answering genuinely different questions.

About Cognilium Cognilium builds AI optimization apps for Microsoft Dynamics 365 — companion apps that optimize the pricing, inventory, warehouse and planning decisions your ERP manages but can't optimize. Dynamics is your system of record. Cognilium is your system of intelligence. https://cognilium.ai · https://www.linkedin.com/company/37180269/

Legal AI Ops. We transform legal workflows with agentic AI, copilots, agentic workflows and decision intelligence — built into core workflows rather than beside them, to raise productivity and cut operational overhead. Contract Review Copilot is the contract-review app in that family. It ships as Paralegent AI, in production today. How we build Legal AI Ops — custom AI capabilities on top of legal work, against your playbook and your Dynamics 365.

Bring your own pipeline to a 15-minute call and we will go through the hops with you, one question per hop.

Sources

No external source is cited. The platform behaviour described in §1 is stated as our operating understanding from building on it — see the fact-check note below.

Sources and fact-check
#§ClaimTierSourceVerdict
11FIFO guarantees ordering and exactly-once within a message group; messages in a group are processed seriallyT2 — our operating understanding, from running this architecture. ⚠️ NOT verified against AWS documentation in this session — see noteVERIFY BEFORE IMPORT
21Standard queues make no ordering guarantee and may deliver more than onceT2 — our operating understanding ⚠️ same caveatVERIFY BEFORE IMPORT
32FIFO belongs on stage boundaries with a real dependency and low volumeT2 — ours, and it describes our own designParalegant_TECHNICAL_PROFILE.md §10PASS
43The fan-out stage is deliberately standard to allow parallel consumption across tasksT2 — capability, our own architectural decision and its stated reasonSame profile, §10PASS — load-bearing
53A FIFO queue with a shared group serialises the fan-outT2 — ours, following from claim 1Reading of AWS behaviourPASS
64Idempotent keyed writes, visibility timeout sizing, generous DLQ on fan-outT2 — ours, engineering practiceSame profile, §5.2, §10PASS
6b4aThe two failure signatures — capacity that changes nothing, versus rare unreproducible failuresT2 — ours, diagnostic experienceInternal definitionPASS
75The decision rule — wrong versus merely differentT2 — oursInternal definitionPASS

Tier summary: 0 × T1, 8 × T2 — 0 × T4.

No figures. Our actual visibility timeouts, DLQ thresholds and queue names are in the internal profile and are not published here — they are configuration specific to our deployment, and the reader needs the reasoning rather than our constants.

Disclosure: no client, no throughput claim, no benchmark. Runtime differences are described qualitatively because a measured figure would be our own performance number.

Share this article

Ali Ahmed

Ali Ahmed

AI Solutions Engineer, Cognilium AI

Ali Ahmed is an AI Solutions Engineer at Cognilium AI.

Applied AI AgentsAgentic SystemsRetrieval-Augmented Generation (RAG)LLM Product Engineering
Next in this series
Our contracts live in six places — where should a contract repository actually be?
Chapter 12 · 6 min
In short

Key takeaways

  • FIFO guarantees order and exactly-once within a message group — and processes that group serially. If everything shares a group, you have built a serial system.
  • Standard queues make no ordering promise and can redeliver, and in exchange they scale as wide as you can consume them.
  • Use FIFO between pipeline stages where one thing genuinely must finish before the next starts, and where volume is low enough that ordering costs you nothing.
  • Use standard inside the stage that fans out. Putting independent work on a FIFO queue serialises the part of the system that was meant to run wide.
  • Idempotent writes make at-least-once delivery a cost question rather than a correctness one.
  • Decide per hop, not per system — ask whether out-of-order processing would be wrong or merely different.
What goes wrong

Common mistakes to avoid

  • Choosing one queue type for the whole pipeline. The stage boundaries and the fan-out are answering different questions.
  • Putting independent chunk work on a FIFO queue. The queue becomes your runtime, not the model.
  • Treating redelivery as a bug. It is usually the queue correctly assuming a slow worker had failed — fix the visibility timeout, not the queue type.
  • Appending results instead of keying them. Idempotency is what makes at-least-once harmless.

Frequently Asked Questions

Find answers to common questions about the topics covered in this article.

Still have questions?

Get in touch with our team for personalized assistance.

Contact Us

Still have a question this did not answer?

The person who wrote this article answers these. Describe your setup and what you are stuck on — you will get a straight answer, including where we think the approach is wrong.