AWS Cloud Architecture•Part 5: Security, IAM, Messaging & Enterprise Deployments (51 - 65)
Amazon SQS vs Amazon SNS.
In Simple Words:
- SQS (Queue / Pull Model): Messages sit in a queue until consumer workers pull and process them. Great for decoupling asynchronous background tasks.
- SNS (Pub-Sub / Push Model): Fan-out publisher that pushes a single notification simultaneously to thousands of subscribers (Lambdas, SQS queues, webhooks).
typescript
// SNS Fan-out to SQS Queue:
import { SNSClient, PublishCommand } from "@aws-sdk/client-sns";
const sns = new SNSClient({});
await sns.send(new PublishCommand({
TopicArn: "arn:aws:sns:us-east-1:123456789:NewOrderTopic",
Message: JSON.stringify({ orderId: "ord_101", total: 49.99 })
}));