Integration
D2 · Resilient
D3 · Performance
~1 phút đọc

Messaging: SQS, SNS, EventBridge

Hiểu sự khác nhau giữa queue, pub/sub, event bus. Khi nào chọn loại nào.

sqs
sns
eventbridge
messaging
fanout

Sơ đồ tổng quan

Đang tải sơ đồ…

SQS

  • Standard: at-least-once, best-effort ordering, unlimited throughput.
  • FIFO: exactly-once processing (dedup 5 phút), strict ordering theo MessageGroupId, 300 TPS (3000 với batching).
  • Visibility timeout 0s–12h, nên > 2x thời gian xử lý max.
  • Long polling (WaitTimeSeconds ≤ 20) giảm số request rỗng.
  • DLQ sau N lần receive fail; cần cùng loại (Standard ↔ Standard, FIFO ↔ FIFO).
  • Retention 1 phút – 14 ngày; message size tối đa 256 KB (dùng S3 Extended Client cho lớn hơn).

SNS

  • Pub/Sub push tới subscriber: HTTPS, email, SMS, Lambda, SQS, Kinesis Firehose, Application endpoint (mobile push).
  • Fan-out pattern: SNS → nhiều SQS queue (mỗi consumer buffer riêng).
  • Message Filtering theo attribute để subscriber chỉ nhận subset.
  • SNS FIFO tích hợp SQS FIFO cho ordered fan-out.

EventBridge

  • Event bus với pattern matching sâu (content-based).
  • Nhiều bus: default, custom, partner (SaaS integration).
  • Schema Registry + code binding; Archive & Replay.
  • EventBridge Pipes để point-to-point (source → filter → enrich → target) mà không cần code.
  • EventBridge Scheduler (mới): cron / rate / one-time, tin cậy hơn CloudWatch Events Scheduled.
Info
SNS nhanh, đơn giản. EventBridge mạnh về routing phức tạp, tích hợp SaaS, audit event. Đề thi ưu tiên EventBridge cho event-driven cross-service.