An image-processing request can return successfully while the actual work is still waiting in a queue. Later, a worker might lose its network connection, encounter an unsupported image or finish an output before crashing. If the application records only “processing” and “done,” these situations become difficult to distinguish.
A more useful design records what the job is doing, what happened during each attempt and what recovery action is available. The following is an application-level design proposal, using Amazon SQS documentation to ground the queue behavior. The state names and data model are suggestions, not built-in SQS features.
Define the job's states before its dashboard
Start with a small state machine:
queued → running → succeeded
running → retry_wait → queued
running → failed
Define the meaning of every transition. “Queued” means the job is eligible for work. “Running” means an attempt currently owns an application lease. “Retry_wait” means another attempt is allowed after a recorded time. “Failed” means automatic attempts have stopped and a reason is available.
Reserve “succeeded” for a verified, durable output with its reference recorded. Completing a resize function alone is insufficient if uploading the result failed afterward.
Keep business state in a durable job record. A queue message supplies work to a consumer; it does not provide the full history a user or operator needs. Also plan for the gap between saving a job and enqueueing it, using a transactional outbox or a reconciler appropriate to your storage system.

Concept illustration: proposed application states, not native SQS states.
Separate the job from its attempts
Use a stable job ID across retries and a new attempt ID for each execution. Record the input version and transformation specification so an operator can identify what the job was supposed to produce.
A compact job record might include state, created_at, updated_at, attempt_count, next_retry_at, last_error_code and output_reference. An attempt record can add worker ID, started_at, heartbeat_at, finished_at, current_stage and a sanitized error summary.
These fields answer different questions. The job tells the user whether work is complete. The attempts explain how the system reached that result. Keep stage names small and stable, such as download, decode, transform, encode and upload.
Handle duplicate delivery explicitly
AWS documents that SQS standard queues can deliver a message more than once and recommends idempotent applications. A repeated message must therefore be safe to encounter. SQS at-least-once delivery
Use the stable job identity to recognize completed work and prevent duplicate external effects. Output creation, notifications and downstream events each need an explicit deduplication strategy. A log statement saying “already processed” does not protect an unguarded notification sent just before it.
Include recovery for the crash window where an output exists but success was not recorded. An attempt-specific output reference and a reconciliation check can help distinguish reusable work from incomplete artifacts. Document which component is responsible for cleanup.
Give running work a measurable lifetime
SQS visibility timeout temporarily hides a received message. If it is not deleted before that timeout expires, it can become available again. AWS provides ChangeMessageVisibility to adjust the timeout; visibility alone does not guarantee exactly-once processing. SQS visibility timeout
For long work, monitor progress and extend visibility when appropriate. Separately maintain the application lease and heartbeat used by the job record. Do not present a job as healthy merely because its last state was “running.”
A stale-attempt check should compare heartbeat age with the expected behavior of that stage. A large encode can legitimately take longer than a small metadata read. When ownership expires, ensure an old worker cannot later publish an authoritative completion. Lease expiry is a recovery signal, not proof that the original process stopped.
Retry the failure that can actually recover
Classify failures before choosing the next transition. A temporary storage outage may justify another attempt. An unsupported input format normally needs a changed input or implementation. An authorization error may need configuration repair instead of repeated execution.
Set an attempt limit and an elapsed-time budget. Use backoff with jitter for eligible transient failures, and account for retries already performed by clients or SDKs. AWS explains that retries can increase load on an overloaded service, while jitter helps avoid synchronized retry bursts. Timeouts, retries and backoff with jitter
Record the classification and next eligible time. Keep detailed diagnostics in access-controlled logs; expose a useful, safe explanation to the user. Raw storage URLs, image metadata and request credentials do not belong in a public status response.
Make dead-letter recovery an operated workflow
An SQS dead-letter queue isolates messages that were not processed successfully. Its redrive policy uses maxReceiveCount, which concerns message receives rather than your application's completed attempt count. Inspect both when diagnosing failures. SQS dead-letter queues
Provide an operator view showing the job, last attempt, failure category and relevant deployment version. Reconcile dead-lettered messages with application state so users do not see “running” indefinitely.
Before redriving, identify what changed: a repaired dependency, corrected permission or deployed fix. Recheck whether an output already exists, then replay a controlled subset and observe the result. Replaying the entire backlog into an unresolved failure only creates more attempts.

Concept illustration: a proposed recovery workflow. Stop replay while the cause remains unresolved; any wider replay still requires capacity checks and monitoring.
Choose metrics that support a decision
Track end-to-end completion time, queue waiting time, stage duration, exhausted retries and stale attempts. Break failures down by a bounded error category or processing version. Keep individual job IDs in logs or traces rather than high-cardinality metric labels.
Queue metrics are supporting evidence. AWS notes that many SQS CloudWatch values are approximate, and its oldest-message metric has special behavior for repeatedly failing messages. Preserve application timestamps so you can measure a user's actual wait independently. SQS CloudWatch metrics
Test the uncomfortable transitions
Before relying on the dashboard, deliberately test a duplicate message, a worker crash, a lost heartbeat, an upload timeout and a permanently invalid file. Also test a crash after output creation but before the completion record is saved.
For every test, ask whether an operator can identify the job's state, explain the last failure and choose the next action without guessing. That is a useful acceptance test for observability: the recorded evidence should support recovery, as well as show that a worker once started.
For the adjacent problem of protecting a user’s edits while background work completes, see Protect Human Edits: Conditional Saves for AI-Assisted Listing Drafts.
Visual disclosure: the cover and diagrams are original AI-generated concept illustrations, not screenshots of a deployed product or evidence of image-processing results.