Database load is measured in average active sessions (AAS): the average number of sessions that are running or waiting at the same time. Database Insights splits the load by wait event, so you can see what the sessions spend their time on:
| Wait event | Meaning |
|---|---|
CPU |
The session is running on the CPU or waiting for a CPU |
IO:DataFileRead |
The session reads a page that is not in memory (shared buffers) |
IO:WalSync, LWLock:WALWrite |
The session waits for the transaction log (WAL) to be written at COMMIT |
Lock:transactionid, Lock:tuple |
The session waits for a row that another transaction is updating |
When the load is higher than the number of vCPUs (the Max vCPUs line), sessions wait for each other.
Open the CloudWatch console, choose Database Insights, then choose Database Instance and rdspg-lab-db. Choose the 30m time range:
CPU wait event. The dashed Max vCPUs line is at 2, the number of vCPUs of db.t4g.micro.
Scroll down to the DB Load Analysis tab:
UPDATE pgbench_accounts ..., the update of the biggest table. Most of its load is also CPU.
Use Top waits, Top hosts, Top users and Top databases to slice the same load by other dimensions. For example, Top hosts shows that all sessions come from the private IP address of the App server.
Scroll up to Alarms:
awsrds-rdspg-lab-db-High-CPUUtilization is in the In alarm state: CPU utilization reached about 95%, above the 50% threshold.
Check your mailbox. Amazon SNS sends the message ALARM: “awsrds-rdspg-lab-db-High-CPUUtilization” within a minute or two of the state change.
The database spends almost all its time on the CPU, and there are many more active sessions than vCPUs. The bottleneck is CPU, not storage I/O or locks. In the next step you give the database more vCPUs and memory.