Skip to content
← Engineering blog
SQSReliabilityServerless

Every Queue Gets a Dead-Letter Queue, No Exceptions

Roughly three dozen SQS queues run behind our backend. Every one of them follows the same one-line rule, and we went looking at what that rule actually buys us.

Sreeraj VR, Founder, Gaim.zone6 min read

Counting queues while we were already poking around the account for the last few posts, we found a little under forty SQS queues behind this backend. Roughly half of them are the main queue for some background job — send this push notification, archive this expired league, rebuild this player's stats. The other half are dead-letter queues, one per main queue, almost without exception. Nobody wrote a rule that says "every queue gets a DLQ" down anywhere we could find. It's just what every queue we looked at actually has.

What a dead-letter queue buys you

An SQS-triggered Lambda function that keeps failing on a message doesn't fail quietly — without a DLQ, SQS keeps redelivering that message until it finally expires and is gone for good, silently, with nothing left to show it ever existed. A dead-letter queue is a second queue the main one is configured to move a message to after it's failed enough times in a row. The message survives. It sits somewhere visible — something as simple as a CloudWatch alarm on "this queue's depth is above zero" is enough to notice it — instead of disappearing into a redelivery count nobody's watching.

The difference, in outcome (simplified)
Without a DLQ:
  message fails → SQS redelivers → fails again → ... →
  message's retention period expires → gone. No record.

With a DLQ:
  message fails → SQS redelivers → fails again → ... →
  maxReceiveCount reached → moved to the DLQ → still there,
  inspectable, alarm-able, replayable once the bug is fixed.

Why we don't skip it for the "small" queues

It would be easy to reason that a low-volume queue — one that handles, say, a once-a-day archival sweep — doesn't need the same safety net as one processing every push notification the app sends. We don't think that holds up: a queue that rarely runs is exactly the one where a silent failure goes unnoticed the longest, because nobody's watching its dashboards closely enough to miss a run that should have happened and didn't. The cost of a DLQ is a few lines in a CDK stack and a queue that sits empty almost always. The cost of not having one is a failure you find out about from a support ticket, weeks later, with no record of what actually went wrong.

Where the pattern comes from

Every one of these queues is defined in its own service's CDK stack, by whoever was building that feature at the time. What kept the pattern consistent across roughly a dozen services and several years wasn't a shared library enforcing it — it's that the first few queues set the convention, each new one was built by copying the shape of an existing stack, and a DLQ-less queue would have looked wrong next to everything around it long before anyone needed to write the rule down. That's a flimsier guarantee than a lint rule would be, and it's the kind of thing we only trust because we just went and checked.

Everything runs without you waiting on it

Download Gaim.zone — notifications, schedules and auction results delivered without you having to refresh anything.

🎯 No real-money auctions · Pure strategy · Free to download