2.4.5. Database Performance: RDS Performance Insights and RDS Proxy
š” First Principle: Database performance problems rarely announce themselves clearly. An application slowdown might look like a network issue, an EC2 issue, or an application bug ā when the real bottleneck is a single database query holding a lock. RDS Performance Insights gives you visibility inside the database engine itself, not just external metrics.
RDS Performance Insights is a database-specific monitoring tool that measures load by tracking what the database is actually doing ā which queries are running, which are waiting, and why.
The primary metric is DB Load ā the average number of active sessions, which represents the demand on the database at any given moment. DB Load is broken down by wait state (what the sessions are waiting for):
| Wait State | What It Means |
|---|---|
| CPU | Queries consuming CPU; may indicate missing indexes or inefficient queries |
| I/O | Waiting for storage reads/writes; may indicate EBS volume IOPS limit |
| Lock | Waiting for another session to release a lock; points to contention |
| Net | Waiting for data to arrive from network |
| Concurrency | Too many concurrent connections |
Performance Insights also shows the top SQL statements consuming load ā this is the direct path to query optimization.
Proactive Recommendations: Performance Insights can now surface automated recommendations (via Amazon DevOps Guru for RDS) ā "this query would benefit from an index" or "connection pool size is too large."
RDS Proxy: The operational problem RDS Proxy solves is connection exhaustion. Serverless applications (Lambda) and microservices can open thousands of database connections ā each idle connection still consumes database memory and file descriptors.
RDS Proxy sits between your application and RDS, maintaining a pool of database connections and multiplexing many application connections over fewer database connections:
Benefits of RDS Proxy:
- Dramatically reduces connection count on RDS
- Handles connection failover transparently (automatic reconnect on Multi-AZ failover)
- Stores credentials in Secrets Manager ā application code never contains database passwords
- Supports IAM authentication for database connections
ā ļø Exam Trap: RDS Proxy is primarily a solution for Lambda + RDS connection exhaustion, but it's also valuable for any application with high connection churn. The exam may present a scenario where Lambda functions are failing with "too many connections" errors ā the answer is RDS Proxy, not increasing the RDS instance size.
Enhanced Monitoring: Separate from Performance Insights, Enhanced Monitoring provides OS-level metrics at up to 1-second granularity ā filesystem usage, process-level CPU, and memory within the RDS instance. Enhanced Monitoring uses a CloudWatch agent running on the DB host and publishes to a dedicated CloudWatch Logs log group.
Reflection Question: A web application's response times increase 10x during peak traffic, but CloudWatch shows RDS CPU at only 40%. Performance Insights shows DB Load is high with 90% of wait time in "Lock" state. What is the most likely cause and next diagnostic step?