Where does RDS spend actually go?

An RDS bill is a handful of separately metered line items. RDS cost optimization means knowing which of them your sizing decisions control, because right-sizing only moves some of them.

Line item What drives it Can right-sizing reduce it?
Instance hours Instance class, running time Yes, through a smaller class or family change
Allocated storage (GB) Provisioned size, not used size Partly. Storage cannot be shrunk in place (see the allocated storage section below)
Provisioned IOPS and throughput io1/io2 IOPS, gp3 extras above baseline Yes, if the provisioned performance exceeds measured demand
Backup storage beyond free allocation Retention period, manual snapshots, change rate No. This is a retention policy decision
Multi-AZ Standby replicates instance and storage Indirectly. It multiplies whatever you size, so cuts count twice
Data transfer Cross-region, internet egress, cross-AZ app traffic No. This depends on architecture

Instance hours and storage usually dominate, so they are where engineering effort pays back. Effort only pays back where the absolute numbers are large.

Illustrative estimate (assumed numbers, not a benchmark)

Monthly savings = monthly instance + storage cost × reduction %

  • Assumed large Multi-AZ cluster at $8,000/month with a 25% cut gives $2,000/month.
  • Assumed small database at $120/month with the same cut gives $30/month.

If profiling, testing, and a maintenance window take two engineer-days, the large cluster recovers that cost in the first month. The small database may never recover it. Start with the largest instances and clusters, and leave small databases alone unless the change is trivial.

How does right-sizing with Performance Insights work?

The method has four parts, and each one feeds the next:

  1. Measure load, not utilization. Performance Insights repeatedly samples the database's active sessions and records what each session is doing: running on CPU, or waiting on a specific wait event such as a data file read, a log write, or a lock. It also records which SQL statement the session was executing. Averaging those samples gives database load in average active sessions (AAS). You can slice it by wait event, by SQL statement, and by other dimensions such as user or host.
  2. Remove avoidable load. The Top SQL view shows which statements generate most of that load. Fixing the worst of them (indexes, batching, rewriting scans) shrinks the workload the instance has to carry.
  3. Size compute and memory against the post-fix peak. Compare the remaining AAS with the vCPU count of the current class and the candidate smaller class. Check memory and cache behaviour with CloudWatch metrics. Only CPU-bound load near the vCPU count argues for keeping or growing the class.
  4. Size storage separately. Instance class and storage are independent decisions on RDS. IOPS and throughput come from CloudWatch storage metrics. Allocated size can only be reduced by migrating to a new instance.

Performance Insights is enabled per DB instance, and support depends on the engine and instance class. Confirm that it is enabled and that its retention covers your observation window before you rely on it. Everything else in this article builds on that data.

Why is average CPUUtilization a poor right-sizing signal?

CloudWatch's CPUUtilization is usually viewed as an hourly or daily average. That smooths away the bursts that drive user-facing latency. An instance averaging 25% can still be pinned at 100% for twenty minutes during a nightly batch. The metric also reports only CPU. A database whose sessions are waiting on storage reads or row locks can show low CPU while queries queue.

Performance Insights measures database load: the average number of active sessions (AAS) running or waiting at any moment. Compare it with the instance's vCPU count:

  • AAS well below vCPUs: the instance has headroom.
  • AAS near or above vCPUs: work is queuing.

Load alone doesn't tell you why work is queuing. Grouping by wait event does. If most load is CPU time, the engine needs more compute. If it's dominated by I/O waits (data file reads, WAL or log writes), the bottleneck is storage throughput, IOPS, or a working set that doesn't fit in memory. If it's lock or latch waits, the cause is contention in the application. Only CPU-bound pressure justifies a larger instance class. Adding vCPUs to a lock-bound workload wastes money and fixes nothing.

You can pull this data with aws pi get-resource-metrics. Pass --service-type RDS, the instance's DbiResourceId as --identifier, and a metric query for db.load.avg grouped by db.wait_event, along with a time range and period.

Retention is a trade-off. The free tier keeps only a short window of history, and longer retention is billed. A short window can miss weekly jobs and month-end reporting peaks. Make sure your window covers at least one full business cycle before you downsize.

#!/usr/bin/env bash
set -euo pipefail

DB_INSTANCE="orders-prod-db"   # placeholder instance identifier
REGION="us-east-1"

RESOURCE_ID=$(aws rds describe-db-instances \
  --region "$REGION" \
  --db-instance-identifier "$DB_INSTANCE" \
  --query 'DBInstances[0].DbiResourceId' \
  --output text)

START=$(date -u -d '7 days ago' +%Y-%m-%dT%H:%M:%SZ)
END=$(date -u +%Y-%m-%dT%H:%M:%SZ)

aws pi get-resource-metrics \
  --region "$REGION" \
  --service-type RDS \
  --identifier "$RESOURCE_ID" \
  --start-time "$START" \
  --end-time "$END" \
  --period-in-seconds 300 \
  --metric-queries '[{"Metric":"db.load.avg","GroupBy":{"Group":"db.wait_event","Limit":10}}]' \
  --output json > db_load_by_wait_event.json

Fetches Performance Insights average active sessions at 5-minute resolution, grouped by wait event, so you can tell CPU-bound load apart from I/O-bound and lock-bound load before you change the instance class.

Should you fix queries before changing the instance?

Yes, almost always. Instance size is a response to load, and much of that load is often avoidable. The Top SQL view in Performance Insights ranks statements by their contribution to database load (average active sessions) and breaks that load down by wait event. Three patterns show up repeatedly:

  • Missing indexes. A single statement dominates load, mostly as CPU or I/O waits, and its execution plan shows a full table scan where a selective filter should be used.
  • N+1 queries. A cheap, nearly identical statement runs thousands of times per request cycle. Each execution is fast. The cost is in call volume, and the fix belongs in the application's data-access layer, usually batching or a join.
  • Heavy scans. Reporting or export queries read far more rows than they return, which pushes hot data out of the buffer cache and raises read I/O for every other query.

A typical fix starts with the top statement. Run EXPLAIN against it with realistic parameters. If the plan shows a sequential scan on a large table filtered by, say, customer_id and status, add a composite index on those columns. Then confirm two things: the new plan uses an index scan, and the statement's share of load drops in Performance Insights.

An index or a batched query costs engineering time and a small amount of storage. An oversized instance costs money every hour it runs. Order also matters. Right-sizing measured against pre-fix load sizes for a workload you are about to remove. Fix the queries first, collect a fresh observation window, and then decide on the instance.

-- PostgreSQL on RDS. Statement taken from Performance Insights Top SQL.
-- Use realistic parameter values, not placeholders that match nothing.
-- EXPLAIN ANALYZE executes the query, so run it only on read-only statements
-- (or on a replica/clone) and outside peak hours.
EXPLAIN (ANALYZE, BUFFERS)
SELECT id, total_amount, created_at
FROM orders
WHERE customer_id = 48213
  AND status = 'pending';

-- What to look for in the output:
--   Seq Scan on orders
--     Filter: ((customer_id = 48213) AND (status = 'pending'::text))
--     Rows Removed by Filter: <large compared to rows returned>
--     Buffers: shared read=<high>
-- Many rows read and discarded means the filter has no index to use.

-- Add a composite index on the filter columns.
-- CONCURRENTLY avoids blocking writes on a busy table. It cannot run inside
-- a transaction block and takes longer than a plain CREATE INDEX.
CREATE INDEX CONCURRENTLY idx_orders_customer_status
    ON orders (customer_id, status);

-- Refresh planner statistics so the new index is costed correctly.
ANALYZE orders;

-- Re-check the plan. Expect an Index Scan or Bitmap Index Scan using
-- idx_orders_customer_status, few rows removed, and far fewer buffers read.
EXPLAIN (ANALYZE, BUFFERS)
SELECT id, total_amount, created_at
FROM orders
WHERE customer_id = 48213
  AND status = 'pending';

-- Then confirm in Performance Insights that this statement's share of
-- average active sessions has dropped before you evaluate instance size.

An EXPLAIN (ANALYZE, BUFFERS) on a top PostgreSQL statement shows a sequential scan. A concurrently built composite index on the filter columns replaces it, and a second EXPLAIN verifies the new plan.

How do you decide whether to downsize an RDS instance?

size against the new baseline. Use the busiest recurring window, such as month-end batch or the daily traffic peak, rather than the daily average. A downsize roughly halves CPU and memory, so ask whether that window would still fit in half the box.

Signal What to check at peak Why it matters after downsizing
CPU Max and p95 vCPU load in Performance Insights Half the vCPUs means queueing sooner
FreeableMemory Minimum, not average Less RAM means a smaller buffer cache
Buffer cache hits Hit ratio and ReadIOPS trend Lower hit rates turn into disk reads
Network/EBS throughput Peak throughput vs. class limits Smaller classes can have lower caps

Low CPU alone does not justify a downsize. If FreeableMemory already dips low at peak, a smaller class will evict hot pages, and the saved compute cost turns into extra storage I/O and higher latency. You also lose headroom for unplanned spikes, ad-hoc batch jobs, and the cold cache on a Multi-AZ standby after failover.

Burstable classes look cheap, but sustained load drains CPU credits. Once they run out, the instance is either throttled or, in unlimited mode, billed for surplus credits. They suit spiky, low-baseline workloads, not steady ones.

Illustrative estimate (assumed prices): current class at $1.00/hour, next size down at $0.50/hour, 730 hours/month. Single-AZ saves about $365/month. Multi-AZ doubles that to about $730/month, because the standby is billed too. Compare that with the cost of a latency regression before you commit.

How does gp3 storage compare with gp2 and io1/io2?

gp2 ties performance to capacity: baseline IOPS scale at 3 per allocated GB, so the only way to get more sustained IOPS is to allocate more storage. gp3 decouples the two. Every volume gets baseline IOPS and throughput, and you provision more of either without growing the disk. A gp2 volume allocated at several times its data size purely to buy IOPS is therefore the best migration candidate.

Storage type IOPS model Throughput Best fit
gp2 Scales with GB, burst credits on small volumes Tied to volume size Legacy; rarely the cheapest choice
gp3 Baseline included, extra provisioned independently Baseline included, extra provisioned independently Most OLTP workloads
io1/io2 Provisioned explicitly Scales with provisioned IOPS Sustained high IOPS needing consistent sub-millisecond latency

io1/io2 is still worth paying for when you need sustained IOPS above what gp3 can deliver, or when p99 I/O latency is a hard requirement.

To size gp3, take peak ReadIOPS + WriteIOPS and peak read/write throughput over a representative window that includes batch jobs and month-end runs. Add 20–30% headroom, then confirm that ReadLatency and WriteLatency stay flat at that level. Only provision above the baseline when the data shows you need it. Extra IOPS and throughput are billed separately, and overprovisioning them can erase the savings.

Apply the change with aws rds modify-db-instance using --storage-type gp3, --iops and --storage-throughput. Any storage modification starts an optimization period, and you cannot change storage again until it finishes. Get the numbers right on the first attempt.

#!/usr/bin/env bash
set -euo pipefail
DB=orders-prod-db
START=$(date -u -d '14 days ago' +%Y-%m-%dT%H:%M:%SZ)
END=$(date -u +%Y-%m-%dT%H:%M:%SZ)

peak() {
  aws cloudwatch get-metric-statistics --namespace AWS/RDS --metric-name "$1" \
    --dimensions Name=DBInstanceIdentifier,Value="$DB" \
    --start-time "$START" --end-time "$END" --period 3600 \
    --statistics Maximum --query 'max(Datapoints[].Maximum)' --output text
}

R_IOPS=$(peak ReadIOPS);       W_IOPS=$(peak WriteIOPS)
R_TPUT=$(peak ReadThroughput); W_TPUT=$(peak WriteThroughput)   # bytes/sec

echo "Peak ReadLatency:  $(peak ReadLatency)"
echo "Peak WriteLatency: $(peak WriteLatency)"

awk -v ri="$R_IOPS" -v wi="$W_IOPS" -v rt="$R_TPUT" -v wt="$W_TPUT" 'BEGIN {
  printf "Target IOPS:       %d\n", (ri + wi) * 1.25
  printf "Target throughput: %d MiB/s\n", (rt + wt) * 1.25 / 1048576
}'

aws rds modify-db-instance \
  --db-instance-identifier "$DB" \
  --storage-type gp3 \
  --iops 12000 \
  --storage-throughput 500 \
  --apply-immediately

Pulls 14 days of peak ReadIOPS, WriteIOPS, throughput and latency from CloudWatch, computes gp3 targets with 25% headroom, and applies the gp2-to-gp3 change with one modify-db-instance call.

What can you do when allocated storage is too large?

That matters most for allocated size, because RDS storage only grows. You cannot reduce allocated storage on an existing instance, and restoring from a snapshot gives you a volume at least as large as the source. A cleanup that frees 600 GB inside the database does not lower the bill. The only way to get a smaller volume is to build a new instance at the size you want and move the data into it.

Approach Downtime Engineering cost Main risk
Dump and restore Writes stopped for the whole dump and restore Low; standard tooling Window grows with data size and index rebuild time
Logical replication into a new instance Brief cutover Medium to high; replication setup, lag monitoring, sequence and DDL handling Objects that don't replicate, such as sequences, schema changes, or tables without primary keys
Blue/green-style cutover Seconds to minutes at switchover Medium; check whether your engine supports a smaller green volume Assuming managed tooling resizes storage when it may not, plus endpoint and DNS changes

Dump and restore works for databases small enough that a maintenance window covers the full copy. For larger or always-on systems, replication-based approaches cost more to set up but turn hours of downtime into a short switchover. Rehearse the cutover on a copy of the database first.

When you create the new instance, set a maximum storage threshold on storage autoscaling. Base it on measured growth plus headroom, not on the largest number available. Autoscaling with no sensible ceiling is how a runaway log table or a bloated index turns into permanent allocated storage, and once it grows, you pay for it until you migrate again.

How do you roll out right-sizing changes safely and when should you buy reserved capacity?

Test the change on a copy of production first. Restore a recent snapshot to the target instance class, then replay representative traffic or run your heaviest scheduled jobs against it. A read replica on the smaller class also works and lets you observe real read load before you touch the primary. Compare the same Performance Insights views you used to justify the change: if database load now regularly exceeds the new vCPU count, the smaller class is too small.

Changing the instance class requires a restart. On a Single-AZ instance, that means an outage for the full duration of the modification. On Multi-AZ, RDS modifies the standby, fails over to it, and then modifies the old primary, so the disruption shrinks to roughly one failover. Your application still needs to reconnect cleanly when that happens. Unless you choose to apply the change immediately, it takes effect in the next maintenance window. Pick that window deliberately rather than accepting the default.

After the change, watch load across at least one full business cycle, including month-end batches and weekly reports. A weekday afternoon is not enough. Write the rollback plan before you start: the original class, the expected restart time, and the metric threshold that triggers a revert.

Buy reserved capacity last. A reservation commits you to a size and term, so reserving before you right-size locks in the waste for one or three years. Weigh it against two alternatives:

  • Staying on demand keeps you flexible while usage is still settling.
  • Doing nothing is the most expensive option once the instance is stable.

Who should use this approach?

This workflow suits teams that own RDS instances large enough for the savings to outweigh the effort. In practice, that means:

  • Platform and infrastructure teams responsible for a fleet of RDS instances, who need a repeatable way to decide which ones are oversized rather than relying on gut feel or average CPU graphs.
  • Application teams that own their database and can change queries, indexes, and data-access code. The query-first step only works if someone can ship those fixes.
  • Teams preparing a reservation purchase, who need to settle on stable instance sizes before committing to a term.
  • Teams that inherited databases provisioned for a launch or a migration peak that never recurred, or sized on gp2 by over-allocating storage for IOPS.

You need permission to read Performance Insights and CloudWatch data, to modify instances, and to schedule maintenance windows. You also need someone who can interpret wait events for your engine. The categories (CPU, I/O, locks) are the same everywhere, but the wait event names differ between PostgreSQL, MySQL, and other engines.

When should you avoid right-sizing?

Skip it, or postpone it, in these situations:

  • The database is small. As the illustrative estimate in the first section shows, a cheap instance may never repay the engineering days spent profiling and testing a change.
  • The workload is still changing. During a product launch, a migration, a major schema rework, or rapid customer growth, any baseline you measure is about to be wrong. Wait until load settles.
  • Your observation window is too short. If Performance Insights retention or CloudWatch history does not cover a full business cycle, you cannot see the peaks that matter. Extend retention, or wait for the data to accumulate.
  • You are entering a known peak period. Don't shrink capacity just before a seasonal traffic spike, a quarter-end close, or a planned marketing event. Do it afterwards.
  • Latency headroom is a requirement. If an SLO or contract depends on spare capacity for failover, cache warm-up, or unplanned spikes, the cost of that headroom is deliberate. It is not waste.
  • The bottleneck isn't instance size. If load is dominated by lock waits or the application's connection handling, changing the class in either direction won't fix it. Fix the contention first.
  • You can't absorb the restart. A Single-AZ instance with no acceptable maintenance window, or an application that doesn't reconnect cleanly after a failover, needs that fixed before any class change.
  • The storage guidance doesn't match your engine. Aurora bills storage differently from standard RDS and does not use the gp2/gp3/io1 volume choices or allocated-storage model described above. The Performance Insights and query sections still apply. The storage sections do not.

How can this approach save engineering time?

Cost is only part of the payoff. The same workflow cuts the time engineers spend on database problems:

  • Diagnosis is faster. Grouping load by wait event tells you in one view whether a slowdown is CPU, I/O, or lock contention. That replaces trial-and-error resizing, where a team upgrades the instance, waits to see if latency improves, and then reverts.
  • Query fixes remove recurring incidents. An index or a batched N+1 query is a one-time change. An oversized instance only hides the problem until load grows again, and then the same investigation repeats at a higher price.
  • The scripts are reusable. The Performance Insights and CloudWatch queries above take an instance identifier as input. Run them across a fleet on a schedule, and they become a standing report instead of a one-off investigation.
  • Prioritizing by spend avoids wasted work. Ranking instances by monthly cost before you start keeps engineers off databases where the savings will never repay the effort.
  • Storage changes happen once. Sizing gp3 IOPS and throughput from measured peaks avoids repeated modifications, each of which would trigger a storage optimization period that blocks further changes.
  • Rehearsed rollouts shorten incidents. Testing on a restored snapshot and writing a rollback plan in advance turns a bad resize into a planned revert instead of an open-ended firefight.

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 cost optimization, 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 route's URL or method automatically notifies the services that consume it — no hunting through repos for callers.

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.
  • Consumers learn about a breaking change at review time rather than from production errors.
  • 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.