Question #755
A developer has designed an AWS Lambda function that interacts with an Amazon RDS PostgreSQL DB instance. During load testing, the database returns an error due to exceeding the maximum number of connections. Which solution resolves this issue with the LEAST operational effort?
Set up a standby replica for the DB instance and direct read queries to the replica.
Migrate the database to Amazon Aurora Serverless to automatically handle scaling.
Enable Multi-AZ deployment for the RDS PostgreSQL DB instance.
Use Amazon RDS Proxy and route database requests through the proxy.
Explanation
Answer D is correct because Amazon RDS Proxy is specifically designed to handle connection pooling, which mitigates the issue of exceeding maximum database connections. When Lambda functions scale out, each instance typically opens a new database connection, leading to connection exhaustion. RDS Proxy acts as an intermediary, maintaining a reusable pool of database connections, reducing the need for each Lambda invocation to create a new connection. This solution requires minimal code changes (e.g., updating the database endpoint to the proxy) and no database migration.
Other options are less optimal:
- A: Setting up a replica distributes read traffic but does not solve connection limits on the primary instance for write operations.
- B: Migrating to Aurora Serverless involves significant effort and does not directly address connection pooling.
- C: Multi-AZ improves availability but does not increase connection limits.
Key Takeaway: RDS Proxy is the most efficient way to manage database connections for serverless applications like Lambda, reducing connection overhead with minimal effort.
Answer
The correct answer is: D