Queue delivery and visibility timeout
SQS decouples producers from workers. Standard queues provide at-least-once delivery and best-effort ordering, so consumers must handle duplicates. Receiving a message temporarily hides it through the visibility timeout. Deleting the message after successful processing acknowledges completion; merely receiving it does not permanently remove it. For example, if work lasts 40 seconds but visibility lasts 10, another worker may receive the same message while the first is still processing.
If work lasts 40 seconds but visibility lasts 10, another worker may receive the same message while the first is still processing.
A producer sends a thumbnail job to SQS and receives confirmation that the message was accepted. A worker polls the queue, receives the message body plus a receipt handle, and begins processing. During the visibility timeout, the message is temporarily hidden from ordinary receives. After storing the thumbnail durably, the worker deletes the message using that receipt handle.
Visibility timeout is a lease-like processing window, not permanent ownership. A receipt handle identifies a particular receive attempt; it is not the stable business ID inside the message. If the worker crashes without deletion, the message can become available again. Standard queues can also deliver duplicates, so an apparently generous timeout does not establish exactly-once application effects. Long polling reduces empty receive calls compared with repeatedly polling immediately. Set visibility from realistic processing duration, extend it for valid long jobs where necessary, and retain a maximum recovery bound so failed workers do not hide useful work forever.
A correctly sized visibility window prevents avoidable concurrent duplicates while preserving eventual recovery when a worker crashes before it can acknowledge successful work.
Deleting a message before its durable side effect finishes can lose work permanently; receiving a message should never be mistaken for completing it.