The SQS Decision Most Diagrams Skip: Normal Work vs. Broken Work
Amazon SQS connects producers and workers, but its real design test is failure. Compare the processing path with the signals and controls needed when queue operations break.
AWSSiddhesh TiwariTutorial
Managing hundreds of persistent outbound WebSocket connections requires explicit ownership because a failed worker can drop connections and stop data flow until they are reassigned. The described fleet-management pattern uses Amazon DynamoDB leases, conditional writes, and a global secondary index to ensure one worker owns each connection, renew ownership with heartbeats, and find expired leases for reconciliation. Amazon ECS on AWS Fargate workers poll Amazon SQS for notifications, maintain the WebSockets, and release or transfer ownership during graceful shutdown, failures, and scaling. The design also records desired state, the upstream URL, and the last processed sequence number in the lease item, while clock synchronization supports its time-based expiry. The post identifies heartbeat writes as the dominant DynamoDB cost and recommends provisioned capacity with Auto Scaling for sustained high connection counts, while noting that longer intervals reduce cost but extend failover.
Long-lived WebSocket connections become unmanaged when workers fail, redeploy, or scale independently. The system requires exactly one worker to own each connection, automatic reassignment after failures, safe draining during deployments, and protection against double-claiming.
Use Amazon DynamoDB items as time-bounded leases, with conditional writes for atomic ownership, heartbeats for renewal, and a global secondary index for finding started connections with expired leases. Amazon ECS on AWS Fargate workers receive notifications through Amazon SQS, reconcile orphaned connections, and use graceful shutdown to release ownership during deployments.
DynamoDB conditional writes provide distributed coordination without a separate lock service; a condition on update_item confirms that one worker still owns a connection before changing its lease.
A global secondary index on desired_state and lease_expires_at_ms lets workers query for STARTED connections with expired leases and reconcile connections left unmanaged by failed workers.
Heartbeat writes dominate DynamoDB cost. Increasing the heartbeat interval lowers WCU consumption but requires a proportionally longer lease, increasing the failover window.
Summaries are generated from the original by a language model. Check the original before relying on it.
See the idea
Amazon SQS connects producers and workers, but its real design test is failure. Compare the processing path with the signals and controls needed when queue operations break.
ActiveAdmin needs a full Rails web boundary, while API-only endpoints need a lean controller. Compare the two paths to see where sessions, assets, and browser protections belong.
Keep reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
One useful email. Unsubscribe anytime.