
Answer-first summary for fast verification
Answer: Write orders to an Amazon Simple Queue Service (Amazon SQS) queue. Use EC2 instances in an Auto Scaling group behind an Application Load Balancer to read from the SQS queue and process orders into the database.
## Explanation **Option B is the correct answer** because it provides the most reliable and scalable solution for processing orders quickly during high traffic periods. ### Why Option B is correct: 1. **SQS provides reliable message queuing**: Amazon SQS ensures that orders are not lost even during traffic spikes. Messages are stored durably until they are processed. 2. **Auto Scaling group with ALB**: This allows the system to automatically scale out (add more EC2 instances) when traffic increases, ensuring orders are processed quickly. 3. **Decoupling**: The solution decouples the order submission from order processing, allowing each component to scale independently. 4. **Reliability**: Even if processing instances fail, orders remain in the SQS queue and can be processed by other instances. ### Why other options are incorrect: **Option A**: - Increasing instance size alone doesn't provide horizontal scalability - SNS is a pub/sub service, not a queue - messages can be lost if no subscribers are available - Database endpoint subscribing to SNS topic is not a reliable way to write to a database **Option C**: - SNS doesn't provide message persistence like SQS - If processing instances are busy or fail, messages can be lost - No buffering capability during traffic spikes **Option D**: - Writing to SQS only when CPU thresholds are reached means orders might be lost during the transition period - Scheduled scaling is not responsive to real-time traffic patterns - Reactive approach rather than proactive ### Key AWS Services Used: - **Amazon SQS**: Reliable message queuing service for decoupling components - **Auto Scaling Group**: Automatically adjusts the number of EC2 instances based on demand - **Application Load Balancer**: Distributes traffic across multiple EC2 instances - **Amazon Aurora**: The target database for order storage This architecture ensures orders are written reliably to the database as quickly as possible by providing a scalable, decoupled, and resilient solution.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
No comments yet.
A company has an application that processes customer orders. The company hosts the application on an Amazon EC2 instance that saves the orders to an Amazon Aurora database. Occasionally when traffic is high the workload does not process orders fast enough.
What should a solutions architect do to write the orders reliably to the database as quickly as possible?
A
Increase the instance size of the EC2 instance when traffic is high. Write orders to Amazon Simple Notification Service (Amazon SNS). Subscribe the database endpoint to the SNS topic.
B
Write orders to an Amazon Simple Queue Service (Amazon SQS) queue. Use EC2 instances in an Auto Scaling group behind an Application Load Balancer to read from the SQS queue and process orders into the database.
C
Write orders to Amazon Simple Notification Service (Amazon SNS). Subscribe the database endpoint to the SNS topic. Use EC2 instances in an Auto Scaling group behind an Application Load Balancer to read from the SNS topic.
D
Write orders to an Amazon Simple Queue Service (Amazon SQS) queue when the EC2 instance reaches CPU threshold limits. Use scheduled scaling of EC2 instances in an Auto Scaling group behind an Application Load Balancer to read from the SQS queue and process orders into the database.