Q34 — AWS SAA-C03 Ch.16

Question 34 of 100 | ← Chapter 16

Q1234. A company is running a serverless ecommerce application on AWS. The application uses Amazon APl Gateway to invoke AWS Lambda Java functions. The Lambda functions connect to an Amazon RDS for MySQL database to store data During a recent sale event,a sudden increase in web traffic resulted in poor APl performance and database connection failures.The company needs to implement a solution to minimize the latency for the Lambda functions and to support bursts in traffic. Which solution will meet these requirements with the LEAST amount of change to the application?

Correct Answer: B. Create an RDS Proxy endpoint for the database. Store database secrets in AWS Secrets Manager. Set up the required IAM permissions. Update the Lambda functions to connect to the RDS Proxy endpoint.Increase the provisioned concurrency for the Lambda functions.

Explanation

To address the issue of poor API performance and database connection failures during high traffic events in a serverless e-commerce application, let's analyze the requirements and the options:Key Requirements:Minimize Latency for Lambda Functions: Reduce the time taken to establish database connections. Support Bursts in Traffic: Ensure the database can handle a sudden increase in connections without failing. Least Amount of Change to the Application: Prefer solutions that require minimal modifications to the existing codebase.Solution Analysis:RDS Proxy:Purpose: RDS Proxy is a fully managed, highly available database proxy for Amazon RDS that makes applications more scalable, more resilient to database failures, and more secure. It pools and shares database connections, improving the efficiency of database connections and reducing the latency for Lambda functions.Benefits:Reduces the overhead of establishing new database connections. Handles connection pooling, which is crucial for serverless applications like Lambda that scale rapidly. Requires minimal changes to the application code (just update the connection string to point to the RDS Proxy endpoint).Provisioned Concurrency vs. Reserved Concurrency:Provisioned Concurrency: Ensures that a specified number of Lambda function instances are initialized and ready to respond to requests, reducing cold start times. Useful for applications requiring consistent performance.Reserved Concurrency: Limits the number of concurrent executions for a Lambda function to prevent it from consuming all available concurrency in the account. Useful for preventing one function from monopolizing resources but does not directly improve performance or handle connection pooling.Evaluating the Options:Option A: Update the code of the Lambda functions to open the database connection outside of the function handler. Increase the provisioned concurrency for the Lambda functions. Incorrect: While opening the database connection outside the handler can help reduce latency (connection reuse), it is not as effective as RDS Proxy for handling connection pooling and scaling. Additionally, provisioned concurrency helps with cold starts but does not address the database connection issue directly. Option B: Create an RDS Proxy endpoint for the database. Store database secrets in AWS Secrets Manager. Set up the required IAM permissions. Update the Lambda functions to connect to the RDS Proxy endpoint. Increase the provisioned concurrency for the Lambda functions. Correct: This option uses RDS Proxy to handle connection pooling and reduce latency. It also uses provisioned concurrency to ensure consistent performance. While storing secrets in Secrets Manager and setting up IAM permissions are additional steps, they are good practices and do not significantly increase the complexity of the solution. This option meets the requirements with minimal changes to the application (just updating the connection string).Option C: Create a custom parameter group. Increase the value of the max_connections parameter. Associate the custom parameter group with the RDS DB instance and schedule a reboot. Increase the reserved concurrency for the Lambda functions.Incorrect: Increasing max_connections can help, but it does not address the root cause of connection pooling inefficiency in serverless applications. Reserved concurrency does not improve performance or handle connection pooling. This solution is less effective than using RDS Proxy. Option D: Create an RDS Proxy endpoint for the database. Store database secrets in AWS Secrets Manager. Set up the required IAM permissions. Update the Lambda functions to connect to the RDS Proxy endpoint. Increase the reserved concurrency for the Lambda functions. Partially Correct: This option uses RDS Proxy, which is good, but increasing reserved concurrency does not provide the same benefits as provisioned concurrency for reducing cold starts and ensuring consistent performance. Provisioned concurrency is more appropriate for this use case.Final Answer:B. Create an RDS Proxy endpoint for the database. Store database secrets in AWS Secrets Manager. Set up the required IAM permissions. Update the Lambda functions to connect to the RDS Proxy endpoint. Increase the provisioned concurrency for the Lambda functions.This solution minimizes latency for Lambda functions by using RDS Proxy for connection pooling and ensures consistent performance during traffic bursts by using provisioned concurrency. It requires minimal changes to the application code.