AWS CSA Notes '22: Part 5 of 8 - Integration and Decoupling Services

5 Integration and Decoupling Services

5.1 Amazon Simple Notification Service (Amazon SNS)

SNS uses a publish/subscribe messaging model and event-driven architecture. You can use SNS to send notifications and messages direct to millions of users via SMS, mobile push, or SMTP.

Topic types that Amazon SNS offers - Standard Topics & FIFO Topics:

  • Suitable ...
    • [Standard] ... in scenarios when the order of the message isn't critical and an application can process messages that arrive more than once
    • [FIFO] ... for enhancing messaging between applications where duplicates can't be tolerated or when the order of events and operations is vital.
  • Support ...
    • [Standard] ... a virtually unlimited number of messages per second.
    • [FIFO] ... up to 10 MB per second per FIFO topic or 300 messages per second.
  • Order:
    • [Standard] Don't necessarily preserve the order in which the messages were published
    • [FIFO] Preserve the order in which the messages are published and delivered
  • Deduplication:
    • [Standard] Use a best-effort deduplication technique where a message is delivered at least once; more than one copy occasionally delivered
    • [FIFO] Use a strict deduplication technique where duplicate messages aren't delivered; deduplication happens within a 5-min interval.
  • Allow messages to be sent to ...
    • [Standard] ... various endpoints (SMS, email, mobile push, AWS Lambda, Amazon SQS, and HTTP webhooks.)
    • [FIFO] ... FIFO queues.
  • Use cases: fanning out messages for ...
    • [Standard] ... tax calculation, critical alerting systems, and fraud detection.
    • [FIFO] ... stock monitoring, flight tracking, price update systems, inventory management, and bank transaction logging.

5.2 Amazon Simple Queue Service (Amazon SQS)

Amazon SQS is a managed queue service ... for storing messages as they transit between serverless applications, distributed systems, and microservices.

  • Amazon SQS
    • Offers both Standard and FIFO message queues
    • Features include:
      • Visibility time-out
        • to prevent others receiving and processing the same message
        • default is 30 seconds, maximum is 12 hours
      • Short- and long-term polling
        • [short-] ReceiveMessage only queries a subset, and returns response even when the queue being polled is empty.
        • [long-] Only returns a response as soon as a message arrives in the queue. Times out if no message in the queue for a defined period.
      • list queue pagination
    • A message received and processed from a queue, will stay in the queue until the customer deletes it.

Comparison of  SNS (Simple Notification Service) vs SQS (Simple Queue Service)

  • What:
    • [SNS] Distributed publish service that's good for pushing messages (push mechanism)
    • [SQS] Queueing service that's good for pulling messages and supports at-least-once message (pull mechanism)
  • Purpose:
    • [SNS] Mainly used for processing the same message in multiple ways
    • [SQS] Primarily suitable for decoupling or integrating applications
  • Uses:
    • [SNS] Uses topics
    • [SQS] Uses queues
  • Persistence:
    • [SNS] Persists messages for some configurable duration
    • [SQS] Doesn't have support for message persistence
  • Use:
    • [SNS] Use SNS if multiple subscribers are needed (as multiple subscribers can receive messages at the same time)
    • [SQS] Use SQS if only one subscriber is needed (as more than one subscriber can't receive messages at the same time)


Glossary:
  • AES-256 = 256-bit Advanced Encryption Standard
  • AZ = Availability Zone
  • KMS = Key Management Service {AWS Key Management Service}
  • MFS = Multi-Factor Authentication

Comments