Lambda Is Exhausting Your RDS Connections. Raise the Limit?
Under load, Lambda functions fail with too many connections to RDS. A teammate wants to bump max_connections. Defend the real fix.
Answer key reviewed by Branko Petric
Read first: AWS Databases: RDS and DynamoDB
Your decision
During traffic spikes your Lambda functions start failing with too many connections errors against RDS. A teammate says just raise max_connections on the database. Do you agree, and what do you do instead?
The situation
Your API is backed by Lambda functions that read and write an RDS database. Normal traffic is fine, but during spikes a wave of invocations starts returning errors that the database has too many connections, and requests fail.
Context
The functions open a fresh database connection at the start of each invocation. At peak the platform runs hundreds of concurrent invocations. RDS is a single instance sized for steady load. A teammate has opened the parameter group and wants to raise max_connections to make the errors stop.
Related challenges
- DynamoDB Is Throttling but Capacity Looks Idle. Crank It Up?
DynamoDB throttles some requests while table capacity looks underused. A teammate wants to raise capacity or flip to on-demand. Defend the real cause.
- Your S3 Website Returns 403. Make the Bucket Public?
Objects in S3 return 403 and a teammate wants to turn off Block Public Access to fix it fast. Defend the right way to grant access.
- The t3 Instance Got Slow. Just Size It Up?
An app on a t3 instance crawls under steady load and a teammate wants a bigger instance. Defend what is actually throttling it.
- Access Keys Are Hardcoded on the EC2 Box. Just Rotate Them?
An app on EC2 authenticates to AWS with long-lived IAM user keys in a config file. One leaked. Defend the real fix.