A company runs an order intake API on AWS Lambda. Each invocation opens a new connection to an Amazon RDS for PostgreSQL Multi-AZ DB instance and closes it on completion. During marketing campaigns, concurrency climbs to several thousand invocations per minute, and the database begins rejecting requests with too many connections errors while its CPU stays under 20 percent. The database team also reports that Multi-AZ failover tests leave the API returning errors for several minutes because functions keep retrying against cached DNS entries. The development team can change the connection string and IAM configuration but has no capacity to rewrite the data access layer. Which solution will meet these requirements with the LEAST application change?
Pick an answer to reveal the explanation.
Why this is correct
Correct answer: Create an Amazon RDS Proxy in front of the DB instance and point the Lambda functions at the proxy endpoint with IAM authentication. The proxy absorbs the connection storm and hides failover from the functions, and the only application change is the endpoint the functions connect to. RDS Proxy sits between the application and the database and keeps a pool of long lived connections open to the DB instance. Client connections terminate at the proxy, which multiplexes many short client sessions onto that smaller pool. This is exactly the shape of a Lambda workload: every execution environment opens a fresh connection, runs a handful of statements, and disconnects, so the database spends its memory and CPU on connection setup rather than on query work. AWS lists DB instances that hit too many connections errors and Lambda functions that make frequent short connections as the primary candidates for a proxy. When the pool is exhausted, the proxy queues new requests instead of letting the engine reject them, so latency rises briefly rather than the API failing outright. The second symptom, several minutes of errors during Multi-AZ failover, is also a proxy problem. Applications that cache the DNS answer for the instance endpoint keep sending traffic to the old primary until the cache expires. RDS Proxy bypasses those DNS caches and reconnects to the new primary on the application's behalf, which AWS states reduces failover time by up to 66 percent for Multi-AZ DB instances while preserving client connections. Because the proxy can authenticate clients with IAM and fetch the database secret from AWS Secrets Manager, the functions no longer need to handle credentials in code, and enabling it requires no change to the data access layer beyond the hostname. Creating a read replica and splitting reads and writes treats a connection problem as a read scaling problem. Every write still lands on the primary through the same flood of short connections, replication is asynchronous, and splitting traffic by statement type is a code change the team said it cannot make. Replicas answer throughput questions, not connection count questions. Raising max_connections and moving to a larger memory optimized class is vertical scaling of a resource the workload is not short of. CPU sits under 20 percent, so the engine is starved by per connection overhead, not by capacity. A higher ceiling delays the same failure to a bigger campaign, costs more every hour, and does nothing about the DNS caching that stretches failover. Storing credentials in Secrets Manager and building a pool in a Lambda layer misunderstands the Lambda execution model. A layer only packages code and libraries. Each execution environment still holds its own connections, and nothing in a layer can share a pool across thousands of concurrent environments, so the database sees the same number of connections. Secrets Manager is good hygiene but is not a pooling mechanism. Key exam concept: RDS Proxy solves connection exhaustion and slow failover for serverless and bursty clients, read replicas solve read throughput, and Multi-AZ solves availability. When a stem pairs Lambda with too many connections errors, the proxy is the answer.