LOAD-BEARINGfree
Architecture labTier 13 · unit 19 of 31

The egress bill

The cloud bill for data transfer went up sixteen times in one month. Product traffic is flat, no feature shipped, and the only change was an infrastructure one: the fleet was spread across three availability zones for redundancy. The system as it stands is already on the sheet.

Envelope$5k → $80k/month · same user traffic as last quarter · nothing in the code changed

What the design must do

  • User-facing media is not served through the compute tier
  • Repeated reference-data reads stop crossing a zone boundary
  • The topology change is justified by which line of the bill it removes
  • Nothing about the product behaviour changes

What is already built

This one is brownfield: the system exists, and the exercise is changing it rather than drawing it from nothing. You start with Client, Load Balancer, App Service, SQL DB, Object Store, Search Index already wired up.

The worked envelope

Assumed. 30k requests/s. Each one reads about 60 KB of reference data from the relational store. 150 TB/month of media is served to users. After the zone spread, roughly two thirds of internal calls cross a boundary. Cross-zone transfer is charged in both directions.

Where the $80k actually is
Reference reads30k/s × 60 KB = 1.8 GB/s ≈ 4.7 PB/month
… crossing a zonetwo thirds ≈ 3.1 PB × $0.02/GB = $62,200
Media via the app150 TB × $0.09/GB = $13,800 to the internet
… and againthe same bytes cross a zone first: $1,500
Everything else$3,000
Total$80,500/month

What the numbers decide. The media is the line everyone suspects, because it is the only one that feels like a lot of data. It is 19% of the bill. The reference-data chatter — a read so ordinary that no architecture diagram has ever drawn it — is 77%, and it appeared without a single line of application code changing, because spreading the fleet across three zones turned two thirds of a same-zone call into a billed one.

That is the whole lesson, and it generalises past this lab: the arrows on your diagram are the bill. Nobody prices them because they are drawn as free, and an availability improvement can therefore be a sixteen-fold cost regression with no code review that would have caught it.

The fix follows the arithmetic rather than the intuition. A cache co-located with the application, at a 95% hit rate, takes $62,200 to about $3,100. Putting the media behind a CDN takes $15,300 to roughly $5,300. Total after: about $11,400, for two components and one deleted connection.

The decisions, and what each one costs

Get the itemised bill before drawing anything

Because
The line that pays for the whole exercise is 77% of the total and is invisible on every diagram of this system, while the line everyone would have optimised first is under a fifth — and no amount of reasoning about the architecture would have ranked them correctly
The cost
It is unglamorous, it takes a day, and it usually requires someone in finance to hand over an export nobody has asked them for before
Rejected
Starting from the architecture diagram and optimising what looks heavy, which is how teams spend a fortnight on media delivery and leave four fifths of the bill untouched

A cache beside the application, in the same zone, for the reference reads

Because
The data is read thirty thousand times a second and changes rarely, so a 95% hit rate is free — and the point is not that the cache is faster, it is that a hit never leaves the zone and therefore is never billed
The cost
A staleness window on reference data that used to be read-through, plus a cache tier to size, warm and monitor (Lesson 4.02)
Rejected
Moving the database into every zone, which removes the same transfer and buys three primaries to keep consistent instead of one

Media served from object storage through a CDN, and the path through the app deleted

Because
Bytes that pass through your compute are billed twice, hold a worker for the duration of the transfer, and are cached nowhere; the CDN charges less per GB, absorbs the repeats, and removes the fleet capacity that was doing nothing but copying
The cost
Signed URLs or token auth to replace the access control the application was implicitly providing, and a purge story for content that changes
Rejected
Compressing harder on the existing path, which reduces a bill you should not be receiving at all

Leave the search index and the relational store exactly where they are

Because
Neither appears in the expensive lines once the cache absorbs the repeated reads, and changing things that are not on the invoice is how a cost project becomes a rewrite with a cost justification
The cost
The remaining cross-zone traffic is real and unoptimised, so the number will drift back up as traffic grows and this will need revisiting
Rejected
Redesigning the data tier while you are in here anyway, which is the most reliable way to turn a two-week saving into a six-month project

Components in the reference design

Client
Browser or mobile app
Load Balancer
L7 routing, TLS termination, health checks
App Service
Stateless business logic
SQL DB
Relational, ACID, joins
Search Index
Inverted index / trie, text and prefix
Object Store
S3-style blobs, media, backups
CDN
Edge cache for static and cacheable content
Cache
Redis / Memcached, sub-ms lookups

What not to draw

  • App Service → Object Store — Streaming media through your own compute is the most expensive way to move a byte: you pay to pull it out of object storage, you pay again to push it to the user, you hold a worker for the duration, and nothing caches it anywhere. The bytes should go from storage to a CDN to the user without touching your fleet.

The reference design

The cause was an availability decision. Nothing shipped. Somebody correctly spread the fleet across three zones so that losing one would not lose the service, and in doing so converted the majority of internal calls from free to billed. This is worth sitting with: the change was right, the outcome was a sixteen-fold cost increase, and there is no review process at most companies that would have flagged it — because the cost of an arrow is not part of how anyone reads a diagram.

Two shapes of egress, priced an order of magnitude apart. Traffic leaving for the internet is the expensive one per gigabyte and the one people budget for. Traffic crossing zones inside your own account is cheap per gigabyte and enormous in volume, which is why it wins. A chatty service mesh can genuinely cost more in transfer than the instances it runs on, and it never appears as anything but a single flat line on a bill nobody itemises.

The cache is doing something other than what caches usually do here. Nothing in this lab is slow. The hit rate is not buying latency, it is buying locality — a hit is served inside the zone and therefore is not a billable transfer. That is a different justification from Lesson 4.02's, it leads to a different sizing decision, and it is worth being able to say out loud, because "we added a cache for cost" is a sentence most reviewers have never heard.

What this canvas cannot draw, and you must say anyway. The strongest fix for cross-zone chatter is not on the palette: place the chattiest pairs of services in the same zone and accept a slightly worse failure story, or collapse two services that talk constantly back into one. Zonal affinity, request batching and compression on internal links are all real levers, and none of them is a box you can drag onto a sheet. In a real review you would propose them alongside what is drawn here, with the arithmetic for each — which is the actual deliverable of a cost exercise.

Then make it a number somebody watches. This bill grew for a month before anyone looked, which means the failure was organisational before it was architectural. Cost per request belongs on a dashboard beside latency and error rate (Lesson 14.12), and a change that moves it deserves the same scrutiny as one that moves the others.

What changes at 10×. Every line scales linearly, so the answer does not change — but the decision does. At eight hundred thousand dollars a month, committed-use discounts, direct interconnects and negotiated transfer rates become worth an engineer's quarter, and the architecture stops being the only lever. That is the point where cost work moves from design review to contract negotiation, and knowing which of the two you are in is most of the skill.