SAP-C02 practice question 24 of 35

A solutions architect has developed a web application that uses an Amazon API Gateway Regional endpoint and an AWS Lambda function. The consumers of…

Full set: 689 questions

Domain Continuous Improvement for Existing Solutions

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? (Choose two.)
Answer options
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. Correct answer
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. Correct answer
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

The primary performance issue is the large number of database connections opened by the Lambda function under high load, which can exhaust database resources. Amazon RDS Proxy is a fully managed, highly available database proxy that is designed to solve this problem. It establishes and manages a pool of database connections, allowing Lambda functions to reuse connections from the pool. This significantly reduces the stress on the database and improves scalability. Using the reader endpoint with RDS Proxy correctly directs read-only queries to the read replicas. Additionally, moving the database connection logic outside the Lambda function's event handler is a critical best practice. This allows the connection to be established during the execution environment's initialization phase and reused across multiple invocations, reducing the overhead and frequency of creating new connections.

Why Incorrect

A. The cluster endpoint directs traffic to the primary (writer) instance. Sending read-only queries here would bypass the read replicas, failing to utilize them and potentially overloading the writer.
C. Provisioned Concurrency reduces cold start latency by keeping function instances warm. It does not solve the underlying problem of connection exhaustion and could even worsen it by enabling more concurrent connections.
E. An edge-optimized API Gateway endpoint is for geographically distributed users. The scenario states users are close to the deployment Region, making the current Regional endpoint the more performant choice.

References

1. Amazon RDS Proxy: AWS Documentation

"Managing connections with Amazon RDS Proxy

" states

"RDS Proxy allows applications to pool and share connections established with the database. This improves database efficiency and application scalability... It is especially well-suited for serverless applications such as those built on AWS Lambda".

Source: AWS Documentation

Amazon RDS User Guide

"Using Amazon RDS Proxy

" "Managing connections with Amazon RDS Proxy."

2. Lambda Connection Management: AWS Documentation

"Best practices for working with AWS Lambda functions

" advises

"Initialize database connections outside of the function handler... subsequent invocations processed by the same instance of your function can reuse these resources."

Source: AWS Documentation

AWS Lambda Developer Guide

"Best practices for working with AWS Lambda functions

" "Manage database connections."

3. Aurora Endpoints: AWS Documentation explains that the reader endpoint provides load-balancing for read-only connections across Aurora Replicas. The cluster endpoint connects to the primary instance for write operations.

Source: AWS Documentation

Amazon Aurora User Guide

"Amazon Aurora connection management

" "Aurora endpoints."

4. API Gateway Endpoints: AWS Documentation clarifies that Regional endpoints are best for clients in the same AWS Region

while edge-optimized endpoints are better for geographically distributed clients.

Source: AWS Documentation

Amazon API Gateway Developer Guide

"Choosing an API Gateway API endpoint type to set up

" "Comparing edge-optimized and Regional API endpoints."

Scroll to Top