Question #695
A retail company operates a serverless e-commerce platform on AWS. The platform's inventory service manages product details in an Amazon DynamoDB table. Several other microservices maintain cached copies of product data in different storage solutions. When a product is discontinued, the inventory service deletes it, and all microservices must immediately remove their cached data to prevent outdated information. Which solution ensures immediate deletion across all services?
Enable DynamoDB Streams on the DynamoDB table. Use an AWS Lambda function triggered by the stream to send deletion events to an Amazon Simple Queue Service (Amazon SQS) queue. Configure each microservice to poll the queue and delete the product from the DynamoDB table.
Configure DynamoDB event notifications to publish deletion events to an Amazon Simple Notification Service (Amazon SNS) topic. Subscribe each microservice to the SNS topic and delete the product from the DynamoDB table.
Have the inventory service publish a custom event to an Amazon EventBridge event bus upon product deletion. Create an EventBridge rule for each microservice to detect the deletion event and trigger their logic to remove cached data.
Configure the inventory service to send deletion messages to an Amazon Simple Queue Service (Amazon SQS) queue. Set up each microservice to filter events from the queue and delete the product from the DynamoDB table.
Explanation
Option C is correct because:
1. Event-Driven Architecture: EventBridge enables decoupled communication. When the inventory service deletes a product, it publishes a custom event to EventBridge, which broadcasts it to all subscribed microservices.
2. Immediate Action: Each microservice has an EventBridge rule to detect deletion events and trigger their cache cleanup logic, ensuring immediate consistency.
3. Scalability: EventBridge supports multiple targets, making it ideal for fan-out scenarios.
Other options are incorrect because:
- A: SQS queues are designed for single-consumer processing. Polling the same queue across multiple services would not guarantee all receive the event.
- B: While SNS supports fan-out, the option incorrectly states microservices delete the product from DynamoDB (already deleted).
- D: SQS cannot reliably distribute messages to multiple consumers simultaneously without separate queues.
Key Points: Use EventBridge for real-time event broadcasting in serverless architectures to ensure immediate, scalable, and decoupled actions across services.
Answer
The correct answer is: C