Database Insights showed that the load test is limited by CPU. To remove this bottleneck, you scale up the DB instance, which is called vertical scaling: you change the instance class to one with more vCPUs and memory, run the same load test again, and then scale back down.
| Instance class | vCPUs | Memory |
|---|---|---|
db.t4g.micro |
2 | 1 GiB |
db.t4g.xlarge |
4 | 16 GiB |
db.t4g.xlarge is not in the free tier and is charged per hour, so keep it only for the duration of the test.
Changing the instance class restarts the database. With Apply immediately, the database is unavailable for a few minutes. In production, schedule this change in the maintenance window, or use a Multi-AZ deployment to shorten the downtime.
Choose rdspg-lab-db, then Modify. In Instance configuration:
db.t4g.xlarge (4 vCPUs, 16 GiB RAM).
Choose Continue:
db.t4g.micro → db.t4g.xlarge.
Wait about 10 minutes until the Size column shows db.t4g.xlarge and the Status is Available.
On the App server, run exactly the same command as in step 3.2:
pgbench --protocol=prepared -P 30 --time=300 --client=50 --jobs=2 pglab

The improvement is bigger than the number of vCPUs alone suggests. With 16 GiB of memory, the whole test data (about 750 MB) fits in the shared buffers, so PostgreSQL reads almost nothing from storage. And db.t4g.xlarge starts with more CPU credits than db.t4g.micro.
rdspg-lab-db again and change the instance type back to db.t4g.micro, with Apply immediately.Scaling up is the fastest way to remove a CPU or memory bottleneck, but it has a limit and costs more every hour. Before you scale up, check with Database Insights that the bottleneck really is the instance, and not a missing index or a badly written query.