Q8 — AWS SAP-C02 Ch.1
Question 8 of 75 | ← Chapter 1
Q83. A solutions architect has developed a web application that uses an Amazon API Gateway Regional endpoint and an AWS Lambda function. The consumers of the web application are all close to the AWS Region where the application will be deployed. The Lambda function only queries an Amazon Aurora MySQL database. The solutions architect has configured the database to have three read replicas. During testing, the application does not meet performance requirements. Under high load, the application opens a large number of database connections. The solutions architect must improve the application's performance.Which actions should the solutions architect take to meet these requirements? (Select TWO.)
- A. Use the cluster endpoint of the Aurora database.
- B. Use RDS Proxy to set up a connection pool to the reader endpoint of the Aurora database. ✓
- C. Use the Lambda Provisioned Concurrency feature.
- D. Move the code for opening the database connection in the Lambda function outside of the event handler. ✓
- E. Change the API Gateway endpoint to an edge-optimized endpoint.
Correct Answer: B. Use RDS Proxy to set up a connection pool to the reader endpoint of the Aurora database., D. Move the code for opening the database connection in the Lambda function outside of the event handler.
Explanation
To improve the performance of the web application that uses an Amazon API Gateway Regional endpoint and an AWS Lambda function, the recommended actions are: B. Use RDS Proxy to set up a connection pool to the reader endpoint of the Aurora database.D. Move the code for opening the database connection in the Lambda function outside of the event handler. Explanation: Action B: Use RDS Proxy to set up a connection pool to the reader endpoint of the Aurora database. RDS Proxy provides connection pooling capabilities, allowing multiple Lambda function invocations to share database connections. This helps reduce the number of connections opened and improves overall performance. By using the reader endpoint of the Aurora database, the read replicas can be utilized effectively for handling read traffic. Action D: Move the code for opening the database connection in the Lambda function outside of the event handler. Opening a large number of database connections during high load can impact performance. By moving the code for opening the database connection outside of the event handler, the connection can be reused across multiple invocations, reducing the overhead of establishing a new connection for each request. The connection can be initialized during the Lambda function initialization phase and reused for subsequent invocations. Option A is incorrect because using the cluster endpoint of the Aurora database does not directly address the issue of opening a large number of database connections. It may still result in a high number of connections being opened during high load. Option C is incorrect because the Lambda Provisioned Concurrency feature helps to keep a specified number of functions initialized and ready to respond to an event. While it can improve cold start performance, it does not directly address the issue of opening a large number of database connections. Option E is incorrect because changing the API Gateway endpoint to an edge-optimized endpoint does not directly address the issue of opening a large number of database connections. It is related to the network edge location where the API Gateway is deployed and does not impact the database connection management. Therefore, the recommended actions are B and D to improve the application's performance. B and D.for B:Connect to RDS outside of Lambda handler method to improve performance for D:Using RDS Proxy, you can handle unpredictable surges in database traffic. Otherwise, these surges might cause issues due to oversubscribing connections or creating new connections at a fast rate. RDS Proxy establishes a database connection pool and reuses connections in this pool. This approach avoids the memory and CPU overhead of opening a new database connection each time. To protect the database against oversubscription, you can control the number of database connections that are created.