Cutting an AWS bill by 31% in a month: right-size first, then commit
Two AWS accounts went from $1,444 to about $998 a month. The order we did it in: resize ECS tasks from 30 days of CloudWatch data, clean up public IPs and a NAT gateway, then commit the smaller baseline with a Savings Plan and an RDS reservation.
October's bill for two AWS accounts was $1,444.27, before GST. The estimate for November is $998.14. That is 31% lower. Spend had been climbing since May (from $614 to $1,605 in September), and the plan I wrote in October found most of it was in sizes nobody had questioned.
In this blog we will look at the order the work was done in, the commands that gave us the numbers, and how I checked that the savings add up to the real drop in the bill. Everything is in ap-south-1 (Mumbai). All dollar figures exclude the 18% GST AWS adds in India, so the actual invoice fell a bit more than shown.
The short version of the order: measure, shrink, clean up the network, and only then commit. Commitments are billed every hour whether you use them or not, so the number you commit to should be the number after the shrinking.
Measuring first
The first step was 30 days of CloudWatch data for every ECS service (21 September to 21 October). Average CPU was under 3.5% on every single Fargate service. The web frontend ran two tasks at 1 vCPU and 2 GB each and its average CPU was 0.1%, with a peak of 6.8%. That one honestly surprised me.
This script prints the 30-day average and peak for CPU and memory, one row per service:
#!/usr/bin/env bash
# Print 30-day average and peak CPU and memory for every service in a cluster.
# Usage: ./ecs_usage.sh my-cluster 2026-09-21T00:00:00Z 2026-10-21T00:00:00Z
set -euo pipefail
cluster="$1"
start="$2"
end="$3"
services=$(aws ecs list-services --cluster "$cluster" \
--query 'serviceArns[]' --output text | tr '\t' '\n' | awk -F/ '{print $NF}')
printf '%-24s %8s %8s %8s %8s\n' service cpu_avg cpu_max mem_avg mem_max
for svc in $services; do
row="$svc"
for metric in CPUUtilization MemoryUtilization; do
vals=$(aws cloudwatch get-metric-statistics \
--namespace AWS/ECS --metric-name "$metric" \
--dimensions Name=ClusterName,Value="$cluster" Name=ServiceName,Value="$svc" \
--start-time "$start" --end-time "$end" \
--period 3600 --statistics Average Maximum \
--query '[avg(Datapoints[].Average), max(Datapoints[].Maximum)]' \
--output text)
row="$row $vals"
done
# shellcheck disable=SC2086
printf '%-24s %8.1f %8.1f %8.1f %8.1f\n' $row
done
A one hour period over 30 days gives 720 datapoints per call, which is under the 1,440 limit of get-metric-statistics. list-services returns 10 services per page by default, but the CLI follows the pages for you. One gap: a service with no datapoints (say, one scaled to zero for the whole month) prints None, and printf stops the script there. I didn't bother handling it, since a service with no data is not a resize candidate anyway.
Don't trust the peak alone. Brief spikes to 100% CPU showed up on three services, and every one of them lined up with a deploy or a restart. Fargate's 0.25 vCPU tasks get burst headroom for that. Memory is the opposite: we kept memory where a JVM held half of it, and we kept 2 GB on a jobs worker that had crash-looped on OOM at 512 MB earlier.
Shrinking the tasks
Eight services were resized on 28 October. The frontend went from 2 × 1 vCPU to 2 × 0.5 vCPU, two BI tool tasks went from 1 to 0.5 vCPU (same 2 GB), an analytics web app and three stage/SIT apps went to 0.25 vCPU, and the jobs worker went from 0.5 to 0.25 vCPU with its 2 GB kept. At Mumbai's Fargate price of $0.04256 per vCPU-hour and $0.004655 per GB-hour, that was $114.11 a month.
One more resize was planned and failed. A workflow automation tool at 0.25 vCPU never passed its readiness check, so we rolled it back to the old size the same day itself. I will write about that day separately, because it taught me that every resize is a deploy.
Then something went the other way. We added two monitoring services in the same weeks (0.5 + 0.25 vCPU), which cost $30.10 a month. If you leave new costs like this out of the report, the savings look better than the bill. I kept them in as a negative line.
Cleaning up the network
Two network items came next, and together they are $86.61 a month.
Public IPv4 addresses cost $0.005 an hour each, used or not. That is $3.65 a month per address. We had about 25 of them. Who counts these, right? Four production tasks sat in private subnets with assignPublicIp=ENABLED, so they paid for an address that was never used (their traffic went out through the NAT gateway anyway). Removing those and moving the non-production tasks to private subnets brought it to about 13 addresses, $44.08 a month.
The non-production VPC had a regional NAT gateway active in two AZs. We deleted it on 28 October and put a single zonal one back three weeks later, and the NAT post has the details and the costs on both sides. Net saving: $42.53 a month.
If you have never built a VPC with NAT by hand, Building a VPC by hand explains what these pieces are.
Committing the smaller baseline
This is the biggest section actually: $277.87 a month, 62% of the total.
The production Postgres database (db.m8g.large, Multi-AZ) was not changing size, so it got a reservation. On-demand it was $0.48 an hour. With a 3-year no upfront reservation it's $0.226. That alone was $184.34 a month. The catch is the lock-in till October 2029, and the database has to stay on the m8g family for that.
Everything on Fargate, plus EC2 in the second account, went under a 1-year no upfront Compute Savings Plan at $0.437 an hour: $93.53 a month.
Now, the honest part about the order. The plan said to wait about 30 days after the resizes, then re-run Cost Explorer's recommendation and buy. We didn't wait. Both commitments were bought on 28 October, the same day as the resizes. What saved us is that the hourly figure came from the plan's post-downsizing numbers ($0.437), not from Cost Explorer's recommendation that day, which said $0.621. That recommendation was computed from the oversized tasks. If we had clicked buy on it, about a third of the plan would have sat unused every hour for a year.
So "right-size first" really means: size the commitment on the right-sized footprint. The next post goes into how each commitment works and how that $0.437 was worked out.
Checking that it adds up
A savings report that does not match the bill is useless, management will ask about the gap first thing. So I compared daily run rates. Before is 2 to 27 October, the old setup. After is 19 to 24 November, when everything was in place. Each daily average is scaled to 730 hours, which is what AWS uses for a month.
The daily numbers come from Cost Explorer:
aws ce get-cost-and-usage \
--time-period Start=2026-10-02,End=2026-10-28 \
--granularity DAILY \
--metrics UnblendedCost \
--output json > before.json
aws ce get-cost-and-usage \
--time-period Start=2026-11-19,End=2026-11-25 \
--granularity DAILY \
--metrics UnblendedCost \
--output json > after.json
The end date is exclusive. Run this from the management (payer) account, otherwise you only see the one account. Each call costs $0.01.
Then a small script turns the two files into monthly run rates and checks the section totals against the difference:
#!/usr/bin/env python3
"""Compare two daily run rates from `aws ce get-cost-and-usage --granularity DAILY`.
Usage: python3 run_rate.py before.json after.json [section savings ...]
"""
import json
import sys
HOURS_PER_MONTH = 730
def monthly(path):
with open(path) as f:
days = json.load(f)["ResultsByTime"]
total = sum(float(d["Total"]["UnblendedCost"]["Amount"]) for d in days)
per_day = total / len(days)
return per_day / 24 * HOURS_PER_MONTH, len(days)
def main():
before, n1 = monthly(sys.argv[1])
after, n2 = monthly(sys.argv[2])
print(f"before: ${before:,.2f}/month ({n1} days)")
print(f"after: ${after:,.2f}/month ({n2} days)")
print(f"drop: ${before - after:,.2f}/month ({(before - after) / before:.1%})")
sections = [float(x) for x in sys.argv[3:]]
if sections:
gap = sum(sections) - (before - after)
print(f"sections add up to ${sum(sections):,.2f}, off by ${gap:+,.2f}")
if abs(gap) > 5:
print("more than $5 apart: something is missing from the sections")
sys.exit(1)
if __name__ == "__main__":
main()
python3 run_rate.py before.json after.json 84.01 86.61 277.87 2.39
The four numbers are the sections: downsizing after the new monitoring cost (114.11 minus 30.10), network, commitments, and $2.39 of small CloudWatch changes. They add up to $450.88. October's actual minus November's estimate is $446.13. Under $5 apart, which I was happy with. When the gap is bigger, it usually means a cost moved somewhere you didn't list, like a new service someone started in between.
November's estimate itself is 1 to 24 November as billed, plus 6 days at the 19 to 24 November run rate. Not perfect. But it was the best number available on the 25th, and I'd rather show how it was made than pretend it's a bill.
Where the money went, by service
The by-service view looked strange at first. Fargate dropped from $364.26 to $42.53 and EC2 instances from $188.44 to $57.76, while a new "Savings Plan fee" line went from $35.83 to $314.64. Usage covered by the plan disappears from its own service and shows up as the plan's hourly fee instead. RDS fell from $495.39 to $320.17, and that figure already includes the reservation's monthly fee.
The second account went from $311.52 to $192.51 without a single change inside it. The plan was bought in the first account and covered the second account's EC2 too.
If your services are not on Fargate yet, ECS explained covers how task sizes work.
Two things are still open from the plan: the automation tool at 0.5 vCPU (not tried yet) and shrinking a 200 GiB analytics volume that uses about 14 GB. That second one needs a database switchover, so it waits.