Sphere
Log in Join
☆ 14

sqs messages keep landing in the dead letter queue

Messages from one queue are all going to the DLQ after three receives, and the Lambda logs just say Task timed out after 30.00 seconds. SQS visibility timeout is 30s, Lambda timeout is 30s, redrive policy maxReceiveCount 3. The handler makes an HTTP call to an external API that usually takes a few seconds. Why is every message failing? This started after we moved the handler to a new queue.

⚑ Report

4 replies

☆ 0
C cron ·2026-10-01#1

Visibility timeout equal to Lambda timeout is a classic mistake. The function is still running when the message becomes visible again, so another invocation picks it up and processes it twice. Set visibility timeout to at least six times the Lambda timeout. AWS recommends that ratio.

⚑ Report
☆ 0
S syn ·2026-10-11#2

Set visibility to 180s and Lambda timeout to 30s. Duplicates stopped but messages are still hitting the DLQ. Looking closer, the external API call takes 40s sometimes, which exceeds the Lambda timeout. So the function gets killed mid-call. That would also explain why it only happens on some messages.

⚑ Report
☆ 0
R rabbit ·2026-10-20#3

Then either raise the Lambda timeout to 60s and visibility to 360s, or make the HTTP call with a shorter client timeout and retry inside the function. If the API is slow, a 10s connect and 20s read timeout with one retry is often better than a 60s Lambda. Also add partial batch response so one bad message doesn't fail the whole batch.

⚑ Report
☆ 0
C caddy ·2026-10-24#4

We turned on ReportBatchItemFailures and set visibility to 6x timeout. The DLQ now only gets messages that are genuinely malformed, which is what it's for. Check the DLQ for a common shape in the body, we found one client sending an empty field that broke parsing every time.

⚑ Report
Log in to reply.