A developer is designing a serverless notification architecture for an e-commerce platform. When an order is placed, details must be sent to three downstream systems: fulfillment (which only processes 'Express' orders), marketing (which tracks all orders), and analytics (which only processes orders with a value of $100 or more). The developer wants to minimize costs and operational overhead, and avoid having downstream systems filter out irrelevant messages. Which architecture should the developer implement?
- Publish messages to a single Amazon SNS topic. Create three Amazon SQS queues, one for each downstream system, and subscribe them to the SNS topic. Apply SNS subscription filter policies on the fulfillment and analytics queue subscriptions to filter by message attributes, and leave the marketing subscription unfiltered.Cevap
- BPublish all messages to a single Amazon SQS standard queue. Configure the fulfillment, marketing, and analytics systems to poll the queue. If a system receives a message it does not need, it leaves the message in the queue and relies on a low SQS visibility timeout to allow other systems to retrieve it.
- CPublish all messages to a single Amazon SNS topic. Subscribe three Amazon SQS queues to the topic. Have the consumer applications initialize their AWS SDK clients using hardcoded AWS access keys inside the code to retrieve and filter messages from their respective queues.
- DPublish all messages to an Amazon SNS topic. Subscribe three AWS Lambda functions directly to the topic. Configure the fulfillment and analytics Lambda functions with short timeouts to quickly discard unmatched messages, assuming that database connections and stateful variables inside the functions are automatically cleaned up between execution threads.
Cevap
Publish messages to a single Amazon SNS topic, subscribe three Amazon SQS queues to it, and apply SNS subscription filter policies to route specific messages to the fulfillment and analytics queues while leaving the marketing queue unfiltered.
The correct architecture uses the Amazon SNS fanout pattern combined with subscription filter policies. By publishing all events to a single SNS topic and subscribing separate SQS queues for each downstream service, you achieve complete decoupling. Applying SNS subscription filter policies directly on the subscriptions ensures that only matching messages are sent to the fulfillment and analytics SQS queues, eliminating the need for consumer-side filtering. This minimizes SQS request costs and operational overhead.
Adım Adım Çözüm
Anahtar Kavram
Message routing and fanout using Amazon SNS subscription filter policies and Amazon SQS queues
Alternatif Yöntem
An alternative approach is to use Amazon EventBridge, which natively supports content-based filtering. However, for standard high-throughput messaging patterns involving simple SQS integration, the SNS-to-SQS fanout with subscription filter policies is the standard, cost-effective, and highly scalable pattern tested on the AWS Certified Developer exam.
Tahmini Süre:2m 0s