The Snapshots Added Up to 21 TiB. Deleting Them Freed 687 GiB.

aws finops ebs devops mechanism

When I got back from a week off, I opened Cost Explorer to finish a job I had started before I left: the EBS snapshot bill in our production account. The September monthly view still showed snapshots as one of the bigger storage lines, so I went looking for what was left to cut.

The daily view told a different story. The snapshot line had dropped from about $33 a day to $4.90 a day on September 17, twelve days earlier. The fix had already landed, and I was the one who landed it. The monthly bar mixed sixteen days before the change with twelve days after it and showed an average that described neither. If a cost changed partway through a period, read it at daily granularity before deciding what still needs doing.

The rest of this post covers why that fix worked, why the cleanup I had planned was worth about thirty times less than its numbers said, and a mistake about snapshots I had written down myself.

Snapshots bill on changed blocks

EBS snapshots are incremental. The first snapshot of a volume stores every block that has ever been written. Each later snapshot stores only the blocks that changed since the one before it. You pay for stored blocks, at about $0.05 per GB-month on the standard tier. The volume’s provisioned size never enters the formula.

That makes provisioned size a bad stand-in for snapshot cost, and in our account it was off by two orders of magnitude. These are measured changes between two consecutive daily snapshots:

VolumeProvisionedChanged in 24h
Analytics column-store (×3)1280 GB97.7 GiB each
Time-series database (×3)300 GB6.9 GiB
CI server data200 GB0.18 GiB
Data disk on a stopped instance150 GB0.00 GiB

A column-store database rewrites its data files constantly. Background merges combine small parts into larger ones, and a merged part is a new set of blocks on disk even when the rows inside it are the same. So every daily snapshot of those volumes was close to a full copy. With a lifecycle policy keeping 14 dailies, 13 weeklies and 12 monthlies, those three volumes dominated the whole snapshot bill. The 150 GB disk on a stopped instance cost nothing, which is fair, since it was also the least worth protecting.

On September 17 the column-store and time-series volumes came off the snapshot policy. Before that I checked that each one had another way back. The time-series database ships its WAL to object storage every day, and I confirmed those runs were completing, not just scheduled. The column-store holds observability data that can be rebuilt. Rebuildable data with heavy compaction is about the worst thing you can snapshot daily: you pay for nearly a full copy every day to protect something you would rather regenerate anyway.

The lesson is to judge a volume by its write pattern, not its size. Ask what the volume does all day before you ask how big it is.

Measuring the delta

The EBS direct APIs let you compare two snapshots of the same volume block by block. list-changed-blocks returns the blocks that differ, and list-snapshot-blocks returns every block a single snapshot references. Multiply the block count by BlockSize (512 KiB) and you have bytes.

One trap cost me a wrong answer first. The API returns far fewer blocks per page than --max-results suggests, and the AWS CLI does not paginate this call for you. My first script capped the number of pages, so it reported a floor and labeled it as the total. The loop has to follow NextToken until it runs out:

count=0; token=""
while :; do
  page=$(aws ebs list-changed-blocks \
    --first-snapshot-id "$older" --second-snapshot-id "$newer" \
    ${token:+--next-token "$token"} --output json)
  count=$(( count + $(jq '.ChangedBlocks | length' <<<"$page") ))
  token=$(jq -r '.NextToken // empty' <<<"$page")
  [ -z "$token" ] && break
done
echo "$(( count / 2 )) MiB changed"   # 512 KiB blocks

This is slow on a busy volume, because a 97 GiB delta is close to 200,000 blocks. It is still the only number that tells you what a snapshot actually costs.

Twelve days later: the sediment

On September 29 the account held 1,177 snapshots. Grouping them by description showed that four generations of snapshot jobs had produced them:

  • the current lifecycle policy, the only one with retention;
  • a retired weekly scheme;
  • three lifecycle policies that had been replaced over the years;
  • a nightly job on an old CI server, still snapshotting an instance that had been stopped for months.

There were also leftovers from a message-broker cluster that no longer exists, and backup history from before a volume restore. Only the current policy ever pruned anything. Everything else had accumulated, and a snapshot count that suggests one policy’s settings is really the sum of several jobs that nobody turned off.

I deleted 655 of them, keeping the newest snapshot of each retired volume where its history might still matter, and went from 1,177 to 522. The account has no Recycle Bin retention rule, so those deletions were final. That is worth checking before you start, not after.

Why 21 TiB was really 687 GiB

Before deleting, I had added up the snapshots’ sizes. 529 of the snapshots on the list reported about 21.7 TiB between them. If that were the storage being freed, the cleanup would have been worth more than $1,000 a month.

It freed about 687 GiB, roughly $34 a month.

The reported size of a snapshot is the full volume image it can restore, not the storage it uniquely owns. Fourteen dailies of the same volume each claim the whole disk, but they share almost all of their blocks with each other. Adding them up counts the same blocks fourteen times.

What a deletion frees has to be worked out per source volume, as a chain:

U(chain) = full size of the oldest snapshot
         + Σ changed blocks between each consecutive pair
freed    ≈ U(all snapshots of the volume) − U(the snapshots you keep)

list-changed-blocks works between any two snapshots of the same lineage, not just neighbors, so U(kept) can be computed even when the snapshots you keep are months apart. Do this before you put a number in a ticket. The big saving had already come on September 17, from changing what the policy covered. The sediment cleanup was an order of magnitude smaller, and the summed sizes would have made it look like the headline.

A belief I had to retract

On September 17 I wrote down, with some confidence, that once a source volume is deleted, its snapshots stop being cheap increments and become full standalone copies forever. I used it to explain why retired schemes seemed to cost the most.

It is wrong. Snapshots of a volume keep sharing blocks with each other whether or not the volume still exists. When you delete a snapshot, EBS removes only the blocks no other snapshot references. Deleting the volume changes nothing about snapshot storage.

Old backup schemes keep costing money for a much duller reason: nothing ever deletes their snapshots. The wrong version was worse than useless here, because it pointed the same way as the summed sizes. Both said the sediment was the expensive part, and both were wrong.

Where I stopped

The live policy now holds about 1,080 GiB, roughly $54 a month. Cutting retention to 7 dailies, 4 weeklies and 6 monthlies would save about $12 of that. I left the retention as it was. At this scale, the recovery window is worth more than the money.

One oddity is still open. A small restored data volume has snapshots that hold more than twice its own size, so something on it rewrites a lot of blocks every day. It is the next thing to look at, but at these numbers it is a curiosity, not a cost problem.

What to keep

  • Snapshot cost follows write churn. Measure the daily delta with list-changed-blocks before deciding what to protect, and expect merge-heavy databases to be the outliers.
  • Summed snapshot sizes are not storage. Estimate what a deletion frees per volume chain, or the number in your ticket will be wrong by an order of magnitude.
  • Read cost at the granularity of the change. A monthly bar that straddles a fix shows an average that no day actually had.
$ cat KUBERNETES .md
· 7 min read

The Cluster Used 160 Millicores. Its Requests Needed Six Nodes.

Before our first customer I asked whether three medium nodes could hold production. The cluster was using about 160 millicores of CPU, yet its resource requests kept six nodes busy. Here is why requests, not usage, decide node count, why the autoscalers read requests too, and why the capacity of a cluster is not the capacity of the product when the expensive work runs at a vendor.

kubernetes eks finops devops mechanism
$ cat OBSERVABILITY .md
· 8 min read

We Lost 50 Million Spans and Nothing Logged It.

A deploy repointed every service's traces at a new collector that was sized for a trickle. The collector blocked, the services' SDKs dropped the overflow, and roughly 50 million spans vanished over two hours with no counter and no log line anywhere. The only warning was about the wrong thing. Here is how the loss stayed invisible, how I measured something nothing had counted, and why the real bottleneck was not the one I reached for first.

observability opentelemetry kubernetes devops mechanism
$ cat GIT .md
· 7 min read

84 Repositories Vanished. The Fix Was mkdir.

S3 has no empty directories, and in a fully packed git repository the refs directories are exactly that: empty. A file-by-file sync carried every object intact and dropped the two directories git requires to call something a repository, so 84 of 517 came back unreadable while the database still said they had commits. The migration's health checks stayed green the whole time, because none of them ever open a repository.

git aws s3 gitlab mechanism