📨

AWS Messaging Services Overview: SQS vs SNS vs EventBridge

Jul 17, 2024

AWS Messaging Services: SQS, SNS, and EventBridge

Introduction

  • Topic: Differences between SQS, SNS, and EventBridge
  • Agenda:
    1. Explanation of SQS, SNS, and EventBridge through examples
    2. Feature comparison and usage guidelines

SQS (Simple Queue Service)

  • Overview: Old AWS service for reliable asynchronous communication.
  • Main Concepts:
    • Queues: Temporary holding pools for messages, published by applications.
    • Messages: Can contain any data, usually JSON blobs with size limits.
    • Polling: Mechanism by which applications retrieve and process messages from the queue.
  • Example: E-commerce order processing
    • Order Service: Publishes messages about order states to an Orders Analytics Queue.
    • Analytics Service: Pulls messages from the queue and processes them.
    • Integration with Lambda: SQS automatically polls the queue.
  • Key Features:
    • Decouples services by publishing to a queue.
    • FIFO queues are available for ordered message processing.
    • Limits on message size.

SNS (Simple Notification Service)

  • Overview: Pub/Sub model for high throughput and fan-out scenarios.
  • Main Concepts:
    • Topics: Not holding pools; created with specific themes like “orders”.
    • Messages: JSON blobs with size limits.
    • Publish/Subscribe: Publishers send messages to a topic; subscribers receive a copy.
  • Example: Multiple services (Accounting, Analytics, Dashboard) receiving order updates
    • Order Service: Publishes to an Orders Topic.
    • Services are subscribed to the topic and receive copies of messages.
    • Use of queues in front of services recommended for reliability.
  • Key Features:
    • High throughput, ability to scale with millions of subscribers.
    • Decouples higher-order services from downstream processes.
    • Supports many-to-many communication.

EventBridge

  • Overview: Newer service with additional functionality over SNS.
  • Main Concepts:
    • Message Bus: Similar to topics, used to receive and send events.
    • Events: Generated by applications or AWS services, can integrate with 3rd-party SaaS.
    • Rules: Define which events are sent to which targets.
    • Targets: Endpoints that process events.
  • Key Features:
    • Supports third-party integrations and AWS service events.
    • Message filtering available.
    • Limited to 5 targets per rule, which can be restrictive.

When to Use Which Service

  • SQS:
    • Reliable one-to-one asynchronous communication.
    • Holds messages temporarily, allowing for back pressure and ordered processing if needed.
  • SNS:
    • Ideal for one-to-many fan-out scenarios.
    • High throughput and many subscribers.
  • EventBridge:
    • One-to-many with more flexibility; ideal for service and SaaS integrations.
    • Limited by the 5 targets per rule constraint.

Conclusion

  • SQS, SNS, and EventBridge solve different problems despite their similarities.
  • SQS is useful for message decoupling and ordered processing.
  • SNS is ideal for high throughput and multiple subscribers.
  • EventBridge shines in AWS service and third-party integrations but has a target limit.

Further Learning: Application orchestration on AWS - watch related videos and don’t forget to like and subscribe.