AWS Builder Center

Your Queue Has a Villain: A Choose-Your-Own AWS Incident

A fictional campus event, one stubborn message, and three decisions that can rescue—or repeatedly annoy—your serverless app. Pick your moves before reading the reveals, then challenge the design in the comments.

It is 9:58 AM. Registrations for a campus hackathon open in two minutes.
Your app has one job: register a student and prepare a confirmation. Naturally, this is when one message decides to become the main character.
This is a fictional design exercise, not a production incident report. You are the engineer on duty. Pick your answers before reading the reveals.

The tiny architecture

The API accepts a request and places a registration job on a standard Amazon SQS queue. A Lambda worker processes jobs and stores registration state in DynamoDB. The client can check a separate status endpoint.
Stage
Responsibility
Question to ask
API
Validate and enqueue
Was the job accepted durably?
SQS
Buffer pending work
How long is work waiting?
Lambda worker
Process each registration
Can this operation run twice safely?
DynamoDB
Store registration state
Which state is authoritative?
SQS dead-letter queue
Hold repeatedly failing jobs
Who investigates and replays them?
An accepted job is not yet a completed registration. The UI should show that distinction. A queue is a waiting room, not a success certificate.

Decision 1: One bad job brings friends

A worker receives ten jobs. Nine are processed. One contains an invalid event identifier, and the handler throws.
What do you change?
  • A: Increase memory and hope the invalid identifier develops better manners.
  • B: Handle failures per record and enable partial batch responses.
  • C: Catch everything and report the whole batch as successful.
Reveal: B is the useful move here. In the default batch failure behavior, already processed jobs can return alongside the failed one. With the event source mapping configured for ReportBatchItemFailures, the handler can identify failed records for retry. Returning success for work you did not finish can silently lose it. See  AWS batch error handling .
This example uses a standard queue. FIFO handling needs extra care to preserve order: after a failure, report failed and unprocessed records as described in the same guide.

Decision 2: The duplicate has an alibi

A job writes the registration successfully. The worker crashes before the processing cycle finishes. Later, the same job arrives again.
Your move?
  • A: Assume a new delivery means a new registration.
  • B: Give the logical registration a stable identity and make repeat processing safe.
  • C: Make every timeout enormous.
Reveal: B. Duplicate delivery is part of the design space.  AWS documents at-least-once processing , so partial batch handling alone is insufficient.
For this exercise, use a stable registration key such as event ID plus student ID. Enforce uniqueness atomically rather than doing a separate “does it exist?” check followed by a write. Record progress so a retry can distinguish completed work from unfinished work.
The awkward detail: recording a registration and sending an external email are separate effects. A database flag alone does not magically make them atomic. If the worker crashes between sending and recording, you still need a delivery strategy that tolerates that uncertainty, such as provider-supported idempotency. Decide explicitly what a duplicate confirmation would mean for your users.

Decision 3: The villain keeps returning

The invalid job still fails after repeated attempts. Do you keep retrying forever, delete it without a trace, or isolate it for investigation?
My choice: isolate it with a configured SQS redrive policy and dead-letter queue. Attach an alert, an owner, and a replay procedure. Fix the cause before replaying; otherwise you have built a revolving door with excellent branding. The  AWS configuration guide  covers the redrive and visibility settings.
Visibility timeout also needs enough room for processing and retries. Setting it too short can invite overlapping work; stretching it blindly can delay recovery.

Your five-minute tabletop test

Before deploying, walk through these failures with your team:
  1. Deliver the same logical registration twice.
  1. Put an invalid job between valid jobs in a batch.
  1. Crash immediately after the database write.
  1. Make a downstream service slow.
  1. Replay a repaired job from the dead-letter queue.
For every case, ask: What does the student see, what gets retried, and what tells us something is wrong?

Your turn: break this design

Reply with your choices—1B, 2B, 3: isolate, for example—and one change you would make.
Would you protect the confirmation step first, add better queue-age monitoring, or challenge the architecture entirely? Pick one and tell me the failure you are trying to prevent. A tiny counterexample is more useful than a perfect-looking diagram.
Bonus question: what is the most misleading “success” message an app has ever shown you? 😄
#AWS #Serverless #AWSLambda #AmazonSQS #CloudArchitecture
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article