
Answer-first summary for fast verification
Answer: Store the customer data in an Amazon Simple Queue Service (Amazon SQS) FIFO queue. Create a new Lambda function that polls the queue and stores the customer data in the database.
## Explanation **Correct Answer: D** - Store the customer data in an Amazon Simple Queue Service (Amazon SQS) FIFO queue. Create a new Lambda function that polls the queue and stores the customer data in the database. **Why this is correct:** 1. **Decoupling and Resilience**: SQS provides a reliable, durable message queue that decouples the Lambda functions from the database. During database upgrades, the Lambda functions can still write customer data to the SQS queue without needing to establish direct database connections. 2. **Asynchronous Processing**: The solution creates a separate Lambda function that polls the queue and writes data to the database. This allows for: - Data to be queued during database downtime - Automatic retry mechanisms built into SQS - Processing to resume once the database is available 3. **FIFO Queue Benefits**: Using a FIFO (First-In-First-Out) queue ensures that customer data is processed in the order it was received, which is important for maintaining data consistency. **Why other options are incorrect:** **A. RDS Proxy**: While RDS Proxy can help with connection pooling and management, it doesn't solve the fundamental problem of database unavailability during upgrades. The proxy still needs to connect to the database, which will be unavailable during maintenance. **B. Increase Lambda runtime with retry**: This approach is problematic because: - Lambda functions have a maximum timeout (15 minutes) - Database upgrades can take longer than Lambda's maximum runtime - Retries would fail repeatedly during the entire upgrade period - This approach doesn't provide durable storage for the data **C. Lambda local storage**: This is not a viable solution because: - Lambda local storage (/tmp) is ephemeral and limited (512 MB) - Data in local storage is not durable and can be lost if the Lambda execution environment is recycled - It doesn't scale well and creates complexity in managing data across multiple Lambda instances **Key Design Principles Applied:** - **Decoupling**: Separates data ingestion from database persistence - **Durability**: SQS provides message durability for up to 14 days - **Resilience**: System continues to accept data even when backend services are unavailable - **Scalability**: Both Lambda and SQS can scale automatically based on load
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
No comments yet.
A company hosts an application on AWS Lambda functions that are invoked by an Amazon API Gateway API. The Lambda functions save customer data to an Amazon Aurora MySQL database. Whenever the company upgrades the database, the Lambda functions fail to establish database connections until the upgrade is complete. The result is that customer data is not recorded for some of the event. A solutions architect needs to design a solution that stores customer data that is created during database upgrades.
Which solution will meet these requirements?
A
Provision an Amazon RDS proxy to sit between the Lambda functions and the database. Configure the Lambda functions to connect to the RDS proxy.
B
Increase the run time of the Lambda functions to the maximum. Create a retry mechanism in the code that stores the customer data in the database.
C
Persist the customer data to Lambda local storage. Configure new Lambda functions to scan the local storage to save the customer data to the database.
D
Store the customer data in an Amazon Simple Queue Service (Amazon SQS) FIFO queue. Create a new Lambda function that polls the queue and stores the customer data in the database.