Trung BìnhAWS & Cloud iconAWS & Cloud

Phân biệt SQS, SNS và EventBridge. Khi nào dùng từng service trong kiến trúc event-driven?

Amazon SQS (Simple Queue Service) là managed message queue cho point-to-point async messaging: producer gửi message vào queue, consumer poll và xử lý; message tồn tại cho đến khi consumer xóa (đến 14 ngày); hỗ trợ Standard queue (at-least-once, best-effort ordering) và FIFO queue (exactly-once, strict ordering, 300 TPS base; high-throughput mode hỗ trợ đến 30,000 TPS); Dead Letter Queue (DLQ) cho message xử lý thất bại nhiều lần; Visibility Timeout ngăn 2 consumer cùng xử lý một message. Dùng SQS khi: decouple producer/consumer với different speed, buffer traffic spike, retry failed jobs.

Amazon SNS (Simple Notification Service) là pub/sub messaging: publisher gửi message vào topic, SNS fan-out đến nhiều subscribers (SQS queues, Lambda, HTTP endpoint, email, SMS) đồng thời; không lưu trữ message. Dùng SNS khi: broadcast notification, fan-out một event đến nhiều consumers.

Amazon EventBridge là event bus serverless thế hệ mới, hỗ trợ event routing dựa trên content (filter theo pattern JSON), tích hợp 200+ AWS services và SaaS (Salesforce, Datadog), Schema Registry, event replay, pipes; mạnh hơn SNS cho complex routing. Dùng EventBridge khi: event-driven microservices, cross-account event routing, integrate với SaaS, cần content-based routing.

Pattern phổ biến: SNS → SQS fan-out (SNS fan-out đến nhiều SQS queues để nhiều consumer xử lý độc lập).

Xem toàn bộ AWS & Cloud cùng filter theo level & chủ đề con.

Mở danh sách AWS & Cloud