Certified Solutions Architect Decoupling with SQS and SNS Flashcards
6 cards from real AWS practice questions. Tap to flip, then mark Knew It or Still Learning — missed cards come back until you master them.
Read the first 6 Certified Solutions Architect Decoupling with SQS and SNS flashcards as text
A company is designing an order processing system. When a new order is created, the event needs to be sent to multiple downstream services: an inventory service, a shipping service, and a data analytics service. Each service processes the event independently and at its own pace. The architecture must ensure that if the shipping service is temporarily unavailable, it does not impact the inventory and analytics services. Which architecture provides the best decoupling and reliability for this scenario?
Answer: An SNS topic for new orders, with three separate SQS queues subscribed to the topic. Each service polls its respective queue.
This is a classic fan-out pattern. Publishing a single message to an SNS topic, which then distributes it to multiple subscribed SQS queues, is the ideal solution. This decouples the publisher from the consumers and also decouples the consumers from each other. Each SQS queue acts as a durable buffer, ensuring that if one consuming service is down, its messages are safely stored until it becomes available, without affecting the other services.
What is a fundamental difference between the message consumption models of Amazon SQS and Amazon SNS?
Answer: SQS uses a pull (polling) model where consumers request messages from a queue, while SNS uses a push model to send messages to subscribers.
The core difference in consumption is the mechanism. With SQS, consumers must actively poll the queue to retrieve messages. With SNS, the service pushes the message out to all of its subscribers (like Lambda, SQS, email, etc.) as soon as the message is published to the topic.
An application processes large video files uploaded by users. The front-end service uploads the video to S3 and then sends a message with the S3 object key to a backend processing service. The processing can take several minutes and is resource-intensive. The company wants to ensure that messages are not lost if a processing instance fails, and that processing can scale by adding more instances. Which service is most appropriate for managing the messages between the front-end and the backend processing service?
Answer: Amazon SQS, to queue the processing jobs.
Amazon SQS is a fully managed message queuing service designed for decoupling and scaling distributed systems. It provides a durable and reliable queue to store the processing jobs. If a processing instance fails, the message remains in the queue (after the visibility timeout expires) and can be picked up by another instance, ensuring no jobs are lost. This model also allows for horizontal scaling by simply adding more consumers (processing instances) to pull from the queue.
A developer is using an SQS queue to process financial transactions. They observe that some malformed messages cause the consumer application to crash. When the application restarts, it retrieves the same malformed message and crashes again, preventing other valid messages from being processed. Which SQS feature should be configured to isolate these problematic messages after a certain number of failed processing attempts?
Answer: Dead-Letter Queue (DLQ)
A Dead-Letter Queue (DLQ) is the designated feature for this exact use case. You can configure a source queue with a redrive policy that specifies a `maxReceiveCount`. If a message is received from the queue more than that number of times without being successfully deleted, SQS automatically moves it to the specified DLQ. This isolates the problematic message, allowing other messages to be processed, and lets developers inspect the failed messages in the DLQ to debug the issue.
A consumer application retrieves a message from a standard SQS queue. The processing of the message is expected to take 5 minutes. During processing, another identical consumer instance starts up, retrieves the exact same message, and begins processing it, leading to data duplication. Which SQS parameter was misconfigured and needs to be adjusted to prevent this issue?
Answer: VisibilityTimeout
The Visibility Timeout is a period during which SQS prevents other consumers from receiving and processing a specific message after it has been retrieved by one consumer. If the processing time is longer than the visibility timeout, the message will become visible in the queue again and can be picked up by another consumer. To fix this, the Visibility Timeout should be set to a value greater than the 5-minute processing time.
Which of the following is a primary use case for Amazon SNS, as opposed to Amazon SQS?
Answer: Broadcasting a single event notification to multiple, diverse subscribers simultaneously, such as Lambda functions, SQS queues, and email addresses.
Amazon SNS is a publish/subscribe service designed to send notifications to a large number of subscribers. Its primary function is to fan out messages to multiple endpoints. The other options are characteristic of SQS: distributing tasks to competing consumers, buffering requests, and providing durable message storage.