A company is designing a microservices application where different services need to communicate asynchronously without direct coupling. They require a mechanism for services to publish events and for other services to subscribe to and process these events reliably. The solution must support both point-to-point and fan-out messaging patterns. Which AWS service should be used?
- AAmazon SQS Standard
- BAmazon Kinesis Data Streams
- CAWS Step Functions
- DA combination of Amazon SNS and Amazon SQS
Show answer & explanationAnswer & explanation
Correct answer: D. A combination of Amazon SNS and Amazon SQS
A combination of Amazon SNS and Amazon SQS is the most robust solution. Amazon SNS provides the publish/subscribe (fan-out) capability, allowing a single message to be sent to multiple subscribers. Amazon SQS queues can subscribe to SNS topics, providing durable storage for messages and enabling point-to-point communication between the SNS topic and individual consuming services, ensuring reliable delivery even if a service is temporarily unavailable.
Why the other options are wrong
- A. Amazon SQS Standard is a message queuing service primarily for point-to-point communication. While it can be used for simple fan-out by having multiple producers send to multiple queues, it lacks the inherent pub/sub model of SNS.
- B. Amazon Kinesis Data Streams is for real-time processing of large data streams, not primarily for general-purpose asynchronous messaging between microservices with fan-out and point-to-point needs.
- C. AWS Step Functions is a serverless workflow service for coordinating distributed applications, not a messaging service for direct asynchronous communication.
SNS and SQS for Microservices
Combining Amazon SNS (pub/sub) with Amazon SQS (queuing) creates a powerful and flexible asynchronous messaging system for microservices, supporting both fan-out and reliable point-to-point delivery.
- SNS handles fan-out (one-to-many) messaging.
- SQS provides durable queuing for individual consumers.
- Ensures reliable message delivery and loose coupling.
Memory trick: SNS broadcasts, SQS stores, microservices talk, and no one ignores.