What is RDS right sizing with Performance Insights, and why not just use average CPU?
RDS right sizing means choosing the smallest instance class that still covers your database's measured demand, including peaks and a safety margin. The measurement is the hard part. Many teams look at CloudWatch's CPUUtilization average, see 15%, and conclude the instance is oversized. That conclusion is often wrong.
Why average CPU misleads
An average over hours or days smooths out short bursts. A database that runs at 20% most of the day and saturates for ten minutes during a nightly batch can still show a low average. CPU utilization also misses work that isn't on the CPU. Sessions blocked on disk reads, row locks, commit flushes or client network round trips use little CPU, yet each one still adds latency. A low CPU number can sit on top of a system that is I/O-bound.
Performance Insights measures database load as average active sessions (AAS): how many sessions are running or waiting at any moment. It breaks that load down by wait event, SQL statement, user and host. You can then tell CPU-bound load, which a smaller class would have to absorb, from I/O or lock waits, which a different storage configuration or a query fix might address.
Why do it, and who owns it
The obvious payoff is cost. A less obvious one is a capacity model you can defend: "peak AAS is X against Y vCPUs" is easier to reason about than a guessed instance class. The work should be owned by backend and platform engineers who have production access and are on call. They are the people who will notice a regression first and will have to roll it back.
How does Performance Insights database load map to vCPU headroom?
…be the ones who answer for it.
Performance Insights reports DB load as average active sessions (AAS): how many sessions were working or waiting at a given moment. The dashboard draws a line at the instance's vCPU count. If CPU-state AAS stays under that line, sessions rarely wait for a core. If it crosses the line, sessions are queuing for CPU.
Total load does not tell you whether a smaller instance will fit, so group it by wait event type. Only the CPU slice competes for cores. I/O waits depend on storage throughput and on how much of the working set fits in memory. Lock waits come from contention between transactions. Client and network waits mean the database is idle while it waits on the application. Fewer vCPUs will not reduce those slices. A smaller class can still make I/O worse because it usually comes with less memory for caching.
| Load by wait type (illustrative) | AAS |
|---|---|
| CPU | ███████ 3.5 |
| I/O | ███ 1.5 |
| Lock + Client | █ 0.5 |
| Proposed 4-vCPU line | ────────┤ 4 |
| Current 8-vCPU line | ────────────────┤ 8 |
Next, open top SQL. A few statements often account for most of the CPU load. Fixing one bad plan can free up the headroom a downsize needs.
Averages can hide risk. A minute-level mean of 3.5 on four cores can contain short bursts well above 4. On fewer cores those bursts queue, and p99 latency rises.
The example that follows calls aws pi get-resource-metrics with db.load.avg, grouped by db.wait_event_type. Check the identifier format, period, and dimension names against current documentation before you run it.
#!/usr/bin/env bash
# Pull Performance Insights DB load grouped by wait event type for the last 24h.
# Verify parameter names, allowed periods, and output shape against current AWS CLI docs.
set -euo pipefail
INSTANCE="orders-db-prod" # placeholder DB instance identifier
REGION="us-east-1"
# The PI API takes the DbiResourceId (db-XXXX...), not the instance name.
RESOURCE_ID=$(aws rds describe-db-instances \
--region "$REGION" \
--db-instance-identifier "$INSTANCE" \
--query 'DBInstances[0].DbiResourceId' --output text)
START=$(date -u -d '24 hours ago' +%Y-%m-%dT%H:%M:%SZ) # GNU date syntax
END=$(date -u +%Y-%m-%dT%H:%M:%SZ)
# Average active sessions per minute, split by CPU / IO / Lock / Client and so on.
# A 60s period keeps more of the bursts that hourly averages smooth away.
aws pi get-resource-metrics \
--region "$REGION" \
--service-type RDS \
--identifier "$RESOURCE_ID" \
--start-time "$START" --end-time "$END" \
--period-in-seconds 60 \
--metric-queries '[{"Metric":"db.load.avg","GroupBy":{"Group":"db.wait_event_type"}}]' \
--output json > load_by_wait_type.json
# Top 10 SQL statements by load over the same window, to find tuning candidates.
aws pi describe-dimension-keys \
--region "$REGION" \
--service-type RDS \
--identifier "$RESOURCE_ID" \
--start-time "$START" --end-time "$END" \
--metric db.load.avg \
--group-by '{"Group":"db.sql_tokenized","Limit":10}' \
--output json > top_sql.json
Retrieves per-minute Performance Insights DB load grouped by wait event type, plus the top SQL by load, so you can compare the CPU slice against the proposed vCPU count. Check the parameters against current AWS CLI documentation before you run it.
When should you downsize, and what observation window is long enough?
Three signals together justify a downsize. First, database load (average active sessions) stays well below the vCPU count of the smaller target instance, not just the current one, including at peak. Second, the load that does exist is mostly CPU wait, not I/O, lock, or commit waits. A smaller instance class typically has less network and EBS bandwidth as well as fewer vCPUs, so I/O-bound load can get worse after a downsize even when CPU looks idle. Third, memory is stable. FreeableMemory should not trend downward, and swap usage should stay flat. Halving vCPUs usually halves RAM too, which shrinks the buffer cache and can turn cache hits into disk reads.
Choose an observation window that includes every recurring cycle the database serves. At minimum, cover several full weeks so that weekday and weekend patterns both appear. Make sure the window also contains:
- Overnight batch and ETL jobs
- Month-end or billing runs
- Automated backup windows and any snapshot-heavy periods
- Reporting or analytics queries that only run occasionally
Performance Insights retention can limit this. The default retention is short, measured in days, so it can miss quarterly closes, annual events, or seasonal traffic. If you have not paid for longer retention, use CloudWatch metrics such as CPUUtilization and DBLoad, which CloudWatch keeps at hourly resolution for more than a year, to check the peaks that Performance Insights no longer holds.
Size for the observed peak plus a stated margin, not for the mean. A mean of 1.5 sessions says nothing about a month-end peak of 7. Write the margin down, for example 30% headroom above peak load, so reviewers can challenge the number.
Pre-downsize checklist: memory, I/O, network and connection limits
vCPU is only one of several limits that change when you move to a smaller class. Before you change the class, check each of the following against the target instance, not the current one.
Memory matters most. Within a family, one step down usually halves RAM. If the working set no longer fits in the buffer cache, reads that were served from memory become storage reads. The extra I/O can raise latency and, on provisioned-IOPS storage, cost, which can offset the savings from the smaller instance. Watch for a falling cache hit ratio and rising read IOPS.
Throughput caps are easy to overlook. Network bandwidth and EBS bandwidth are both tied to instance size. Some smaller classes reach their peak figures only in bursts, then fall back to a lower baseline.
Several parameter defaults are calculated from instance memory. In the default parameter groups, max_connections and buffer sizes such as shared_buffers (PostgreSQL) or innodb_buffer_pool_size (MySQL) shrink automatically on a smaller class.
| Metric or limit | What to check | Risk if ignored |
|---|---|---|
FreeableMemory |
Current usage compared with the target class's total RAM | Cache eviction and memory pressure |
SwapUsage |
Any sustained, non-zero trend | Latency spikes from paging |
Cache hit ratio, ReadIOPS |
Hit ratio at peak, and read IOPS trend | Working set spills to storage and I/O cost rises |
| Network throughput | Peak receive plus transmit, compared with the target's baseline | Throttled replication and slow result transfer |
| EBS bandwidth | Peak read and write throughput, compared with the target's cap | I/O queueing even when storage IOPS are available |
DatabaseConnections |
Peak connections, compared with the new derived max_connections |
Connection refusals at peak traffic |
Does one step down fit? An illustrative estimate
Illustrative estimate (assumed numbers, not a benchmark). None of the figures below are measurements. Replace each one with values from your own Performance Insights and CloudWatch data.
The check uses three formulas:
- CPU-bound load = peak average active sessions (AAS) × CPU share of waits
- Projected CPU utilization = CPU-bound load ÷ target vCPUs
- The class fits if projected utilization ≤ (1 − target headroom)
| Input (all assumed) | Current class | Candidate (one step down) |
|---|---|---|
| vCPUs | 8 | 4 |
| Memory | 64 GiB | 32 GiB |
| Peak AAS | 3.0 | 3.0 (assumed unchanged) |
| CPU share of waits | 70% | 70% |
| CPU-bound load | 2.1 | 2.1 |
| Projected CPU utilization | 26% | 52.5% |
| Max allowed at 40% headroom | 60% | 60% |
| Fits? | Yes | Yes, with 7.5 points of margin |
Use peak AAS rather than the mean. A class sized for the average will queue at every daily peak. Take only the CPU share of the load, because sessions waiting on I/O or locks do not consume a vCPU. Keep in mind that the 7.5-point margin is thin. A modest rise in traffic or one new expensive query would use it up.
Memory needs a separate check because the candidate halves it. Suppose the hot working set is 20 GiB (assumed). It still fits in 32 GiB, but the buffer cache gets less of that memory, and connections and the OS also need room. If the working set stops fitting in cache, reads move to storage. The I/O share of waits then rises and the CPU share falls, so the CPU estimate above no longer holds.
How do you execute an RDS instance downsizing safely and verify it?
Execute the change with aws rds modify-db-instance, passing --db-instance-identifier and the target --db-instance-class. By default (--no-apply-immediately), the change waits for the next maintenance window. --apply-immediately starts it now, and it also applies any other pending modifications queued on the instance, so check what is pending first.
On a Multi-AZ deployment, RDS resizes the standby, fails over to it, then resizes the old primary. Downtime is roughly one failover. A Single-AZ instance is unavailable for the whole resize. Either way, connections drop and DNS changes, so confirm that connection pools reconnect and retry before you start. Expect the new instance to start with a cold buffer cache, so early latency will look worse than the steady state.
Resize read replicas to match the primary. Downsize the primary first and the replicas afterward. A replica smaller than its primary may not keep up with replay, and lag will grow.
Parameters defined by formulas such as {DBInstanceClassMemory*3/4} recalculate for the new class. Hardcoded values in a custom parameter group do not. An absolute buffer pool or shared_buffers size tuned for the old instance can overcommit memory on the smaller one.
After the cache warms, compare against your baseline for the same weekday and hours:
- DB load relative to the new vCPU count
- Wait event mix, especially any shift toward I/O waits
- p95 and p99 latency
- Freeable memory and swap
Set rollback triggers before the change. Examples: sustained load above vCPU count, or a p99 regression beyond an agreed threshold. Rehearse the scale-up path in advance. Rolling back is another modification with another failover and another cache warm-up, so it takes time to relieve an instance that is already under pressure.
#!/usr/bin/env bash
set -euo pipefail
DB_ID="orders-prod" # primary instance (placeholder)
REPLICA_ID="orders-prod-ro-1" # read replica (placeholder)
TARGET_CLASS="db.r6g.large" # new, smaller class
# 1. Confirm Multi-AZ and current class, and list anything already queued.
# --apply-immediately would also push these pending changes through now.
aws rds describe-db-instances --db-instance-identifier "$DB_ID" \
--query 'DBInstances[0].{Class:DBInstanceClass,MultiAZ:MultiAZ,Pending:PendingModifiedValues}' \
--output json
# 2a. Default path: queue the resize for the next maintenance window.
aws rds modify-db-instance \
--db-instance-identifier "$DB_ID" \
--db-instance-class "$TARGET_CLASS" \
--no-apply-immediately
# 2b. Alternative: start now (uncomment only after reviewing pending changes).
# aws rds modify-db-instance \
# --db-instance-identifier "$DB_ID" \
# --db-instance-class "$TARGET_CLASS" \
# --apply-immediately
# 3. When the change has run, block until the primary reports available.
# The waiter can return before the resize starts, so confirm the class.
aws rds wait db-instance-available --db-instance-identifier "$DB_ID"
aws rds describe-db-instances --db-instance-identifier "$DB_ID" \
--query 'DBInstances[0].DBInstanceClass' --output text
# 4. Resize the replica only after the primary is done, so the replica
# is never smaller than the primary it replays from.
aws rds modify-db-instance \
--db-instance-identifier "$REPLICA_ID" \
--db-instance-class "$TARGET_CLASS" \
--apply-immediately
aws rds wait db-instance-available --db-instance-identifier "$REPLICA_ID"
# Rollback is the same modify call with the old class: another failover, another cache warm-up.
This AWS CLI sequence checks for pending modifications, then downsizes the primary either in the maintenance window or immediately, and resizes the read replica only after the primary is finished.
When should you avoid downsizing, and what are the alternatives?
Skip the downsize when the evidence points away from CPU. If Performance Insights shows load dominated by lock or I/O wait events, removing vCPUs fixes nothing, and a smaller class often lowers network and storage bandwidth caps as well. If the working set already nearly fills RAM, a smaller buffer cache turns hits into disk reads. Hold off too when retention covers less than a full business cycle, when growth is already planned, or when the current headroom is all that absorbs incidents.
Burstable classes suit only steady, low load. They earn CPU credits below a baseline and spend them above it. Sustained load drains the balance. Depending on the credit mode, the instance is then either throttled to baseline or billed for the surplus, and both tend to happen at peak.
| Option | Fits when | Cost effect | Engineering effect |
|---|---|---|---|
| Query tuning, no downsize | A few statements dominate load | Defers future scale-ups | Ongoing; regressions undo it |
| Read replicas | Read-heavy, lag-tolerant | Adds instances | Read/write routing |
| Storage or IOPS change | I/O waits dominate | Shifts spend to storage | Low |
| Burstable class | Steady low load | Lowest baseline | Credit monitoring |
| Serverless-style capacity scaling | Spiky or idle-heavy | Pay per capacity used | Engine and migration constraints |
| Leave as is | Weak evidence, thin headroom | Unchanged | None |
Tuning creates a dependency. The savings last only while those optimizations survive schema and code changes. A repeatable checklist costs effort once and makes each later review quick.
How OneEnv can help
Disclosure: OneEnv is the product behind this blog.
OneEnv (oneenv.io) is a workspace-based governance platform for the things services share — environment variables, database structure, API routes and validation rules. A change to a shared value is staged on a branch, reviewed once, and then every affected service explicitly approves or rejects it before it goes live, so you can see who a change touches before it ships instead of finding out in production.
Applied to rds right sizing, this is where it helps:
Saves time
- Every service that inherits a shared value is listed in one place, so nobody searches repos and chats to find out who is affected.
- One review per branch replaces coordinating each team separately; each service still keeps its own approve/reject.
- Changing a shared variable is one edit and one review instead of editing every service's
.envby hand.
Saves cost
- Fewer production incidents and rollbacks caused by a shared value, route or column changing under a consumer unannounced.
- Less duplicated configuration to maintain: one shared definition inherited by many services.
- A wrong or stale value is caught at review time by the services it affects, not by a failed deploy.
- OneEnv has a free plan (1 workspace, unlimited services and members, full governance), so trying it costs nothing.
These are qualitative benefits, not measured results — how much you save depends on how many services share the value.
Want to try it? Start at oneenv.io.