Skip to content
Episode 52 · The bill nobody can explain

Cloud building blocks: compute, storage and network

Monday, 9:00: StayHub's first cloud bill since the Singapore region opened is €130,000, up from €96,000, while guests grew 8%. Karim wants to know where €32,000 went.

Every cloud sells the same handful of building blocks under different names. Learn the blocks once and you can build on any cloud.

30 min intermediateVMs vs containers vs serverlessBlock vs file vs object storageGeneric cloud building blocks → AWS/Azure/GCP namesManaged services vs self-hostingVirtual machinesContainers
  1. Problem

    You need to run a hotel booking app: code that serves requests, a database, millions of hotel photos, nightly reports, and a network connecting them, without buying hardware.

  2. Why the simple system fails

    Treating the cloud as 'rent a server and put everything on it' recreates a single fragile machine: photos fill the disk, the database dies with the VM, and you pay for idle capacity around the clock.

  3. Engineering concept

    Decompose the system into compute, storage and network primitives, and pick for each piece the level of abstraction (raw VM, container, function, managed service) that matches its workload.

  4. Technology

    Virtual machines, container platforms, functions; block, file and object storage; managed relational and NoSQL databases; virtual networks and load balancers. On AWS, Azure and GCP under different names.

  5. Trade-offs

    Higher abstraction means less operational work and faster scaling, but less control, more provider-specific behaviour, and cost curves that can flip at high, steady load.

01

The problem

2 min
Monday, 9:00. Karim forwards the bill.
  1. Karim · CTO
    €130,000 this month. Last month €96,000. Guests grew 8%. Singapore doesn't explain €32,000.
  2. Omar · On-call SRE
    No single huge line. Lots of VMs, fast disks, and a big serverless line.
  3. Lina · Senior engineer, your mentor
    Guess first; then we read the bill by building block.
02

The big idea

4 min
Where €32,000 went
The big idea

Match each workload's shape to the building block that's priced for it.

Nobody was careless: each choice made sense to whoever made it. Steady → always on. Bursty or nightly → scale to zero. Bytes users download → object storage behind a CDN.

03

How it works

5 min
Every cloud sells three things
  1. 1
    Compute: three shapes

    A is a whole computer rented by the hour, busy or not. A is your app in a standard box on managed machines. A function runs only when called, billed per call: great for spiky load, a premium on every call when load never stops.

  2. 2
    Storage: block and file

    Block storage is one machine's disk: fast, editable, gone or copied per machine. File storage is a shared network folder.

  3. 3
    Storage: object

    keeps whole files fetched by name over HTTP, one durable copy for everyone, practically unlimited. Photos, backups, exports.

  4. 4
    Network

    A private network, and a move the bytes. StayHub's network side was fine this month.

  5. 5
    Managed services on top

    A (or queue, or load balancer) is run by the provider: you set options, they handle servers, patches and failover mechanics. You still own schema, sizing and restore tests.

04

Watch a decision being made

4 min
Worked example

Lina cuts €29,000 from the bill

About €32,000 of a €130,000 bill is unexplained. Find the waste without slowing anything for guests.

  1. 1Group the bill by building block

    Cost tags per service, sorted by VM, disk, function, storage. Three lines stand out: report VMs €14,000, Singapore block disks €9,000, ranking functions €9,000.

    Why: Sorted by team, mismatches hide. Sorted by block, they show where pricing and workload disagree.

  2. 2Describe each workload's shape

    Report: 1.5 h a night, idle otherwise (about 6% useful). Photos: shared files, copied onto 20 VMs' 2 TB disks. Ranking: ~500 calls/s, never idle.

    Why: The shape decides the block, not the technology people like.

  3. 3Pick the block that fits, and estimate

    Report → scheduled job on VMs created for the run and deleted after: ~€1,000. Photos → the existing object storage + CDN: €0. Ranking → autoscaled always-on VMs: ~€2,000.

    Why: An estimate shows which move to do first and guards against moves that save nothing.

  4. 4Check guests didn't pay for it

    Compare ranking p95 and report finish time before and after; review the bill by block next month.

    Why: A cheaper setup that slows search isn't a saving.

The whole thing in one line: Three mismatches between shape and block, about €29,000 a month saved, no slower pages.
05

In real life

3 min
Rent the blocks versus build your own

Netflix: runs its services on AWS

  • Has publicly described running its streaming services and backend on AWS
  • Uses managed blocks to scale with demand
  • Pays a premium for not owning data centres

Fits when demand swings and speed of change matters most.

Dropbox: storage on its own hardware

  • Has publicly described moving most user files from Amazon S3 to its own system
  • Storage is its core product, huge and steady
  • Needed a large team to build and run it

Fits when one huge, steady workload is the business itself.

06

What goes wrong

3 min
Uploads on an app server's local disk

Scale-in and redeploys replace instances; other instances can't see the files.

Instead

Pre-signed uploads straight to object storage, served by the CDN; instances stay disposable.

Always-on machines for nightly work

You pay 24 hours for 1.5 hours of work.

Instead

Scheduled jobs that exist only while running.

Functions for steady, high load

Pay-per-call is a premium on every request when there's never idle time.

Instead

Containers or VMs for steady load.

07

Trade-offs

3 min
BlockFitsYou pay
Virtual machinesOS-level control; steady loadPatching; idle capacity is easy to buy
Containers on a managed platformMost web services and APIsA platform to learn; idle replicas
Serverless functionsSpiky, event-driven, low-volume workCold starts; expensive at steady volume
Managed databaseAlmost always, until you have the expertiseA premium; fewer versions and extensions
Thursday, 14:00. The database line.
  1. Karim · CTO
    Managed PostgreSQL is €11,000 a month. Plain VMs: about €6,500. Let's run it ourselves.
  2. Omar · On-call SRE
    Then backups, patching, failover and 3 a.m. disk alarms are ours. Nobody here has run Postgres failover in production.
  3. Karim · CTO
    €54,000 a year buys a lot of learning.
08

Your job as tech lead

4 min

Claude Code can write the code for this. You still own the decisions, and you have to know what good looks like to accept or reject its work.

Decisions you own
  • Which compute block each workload gets, by shape: steady ranking → always-on VMs, the nightly report → a scheduled job, bursty thumbnails → functions.
  • Where every file lives: uploads and photos in object storage behind the CDN, never on an instance's disk.
  • How much monthly cost a change may add before it needs your sign-off.
Tell Claude Code
Move StayHub's nightly partner report off the 18 always-on report VMs onto a scheduled job: our setup scripts create VMs at 01:00, the job runs, the VMs are deleted. Keep the output identical: same files, bucket and names. Don't touch the managed PostgreSQL or search ranking. Read from the read replica. Nothing on local disk except temp files. First show a plan: changed files, the schedule, what happens if a run fails halfway, and monthly cost before (about €14,000) and after. Then run it once in staging.
Check before you accept
  • The staging output matches last night's: same files, bucket and row counts.
  • No local paths like /var/app/uploads for anything that must survive the run.
  • The cost estimate is line by line (compute hours × price), against the €14,000 it replaces.
Red flags
  • It saves uploads or generated files on the instance's disk "for now".
  • It moves a never-idle service to functions because they're "pay per use".
  • It reports a saving it never calculated, or says "done" without running the job once.
09

Check yourself

2 min
Q1/3Scenario
After enabling autoscaling, guests report hotel photos randomly returning 404. Photos are uploaded to /var/app/uploads on whichever app instance handled the upload. What's the right fix?
How confident are you?

Next episode: a security scan finds StayHub's bookings database answering on a public IP address, and you have to work out how it got one.

Finished?

Mark it complete to update your skill map.

Go deeper (optional)You don't need this to understand the lesson. Open it when a project needs the details: Technical deep dive, Interactive simulation, Visual diagram, Analogy, Check your understanding, Practice ladder, Explain it yourself.
10

Technical deep dive

Bytes straight to storage
Worked example

Lina cuts €29,000 from the bill

The monthly bill is €130,000 and about €32,000 of it is unexplained. Find the waste and fix it without slowing anything down for guests.

  1. 1Group the bill by building block

    Use cost tags per service and sort by VM, block disk, function, object storage, database, network. Three lines stand out: report VMs (€14,000), Singapore block disks (€9,000), ranking functions (€9,000).

    Why: Bills sorted by team hide mismatches. Sorted by block, they show where a pricing model and a workload disagree.

  2. 2Describe each workload's shape

    Report: 1.5 h a night, idle the rest. Photos: shared files read by everyone. Ranking: ~500 calls/s on average, never idle.

    Why: The shape (steady, bursty, nightly, shared) is what decides the right block, not the technology people like.

  3. 3Pick the block that fits

    Report → a scheduled job on VMs created for the run and deleted after. Photos → the existing object storage + CDN; delete the disk copies. Ranking → always-on VMs with autoscaling.

    Why: Scale-to-zero for nightly work, always-on for steady work, one shared copy for shared bytes.

  4. 4Estimate before moving

    Report: €14,000 → about €1,000. Disks: €9,000 → €0. Ranking: €9,000 → about €2,000. Total saving about €29,000 a month.

    Why: A rough estimate tells you which move is worth doing first (the report) and guards against moves that save nothing.

  5. 5Check guests didn't pay for it

    Compare ranking p95 and report finish time before and after; review the bill by block next month.

    Why: A cheaper setup that slows search isn't a saving. Measuring both money and speed proves the move.

The whole thing in one line: Lina sorted the bill by building block, matched each workload's shape to the block priced for it, and moved the three mismatches, saving about €29,000 a month with no slower pages.
BlockFileObject
Accessed asA disk with a filesystemA network folderHTTP: PUT/GET by key
Shared byOne VM at a time (usually)Many machinesAnyone with permission, anywhere
LatencySub-ms to low msLow msTens of ms per request
Edit in placeYesYesNo: replace the whole object
Typical useOS disks, self-run databasesLegacy shared foldersPhotos, backups, logs, exports
11

Interactive simulation

12

Visual diagram

Click a component

A hotel booking app built from generic cloud blocks. Each node notes the AWS / Azure / GCP equivalents.

13

Analogy

  • Running a kitchenRenting an empty kitchenCloud building blocksA virtual machine
  • Running a kitchenA shared kitchen; you bring recipesCloud building blocksContainers on a managed platform
  • Running a kitchenA caterer, paid per dishCloud building blocksServerless functions
  • Running a kitchenYour own fridge, bolted inCloud building blocksBlock storage
  • Running a kitchenA warehouse of labelled cratesCloud building blocksObject storage
  • Running a kitchenA pantry service that stocks and insuresCloud building blocksA managed database

Where the analogy breaks: you can't rent a kitchen for three seconds. In the cloud you can, which is why paying per use is so tempting for small or bursty jobs.

14

Check your understanding

Q1/3Decision
Match each need to the storage type:
The data directory of a PostgreSQL you run yourself on a VM
A legacy CMS on 3 servers that all read/write the same uploads folder
10 years of invoice PDFs and nightly database backups
Booking records queried by guest, date and hotel
How confident are you?
15

Practice ladder

Step 1 · Trace

How much do the photos weigh?

Estimation Warm-up

StayHub lists 6,000 hotels, each with 40 photos, stored in 3 sizes averaging 500 KB per stored file.

  1. How many GB is that?
  2. With illustrative prices of €0.02 per GB-month for object storage and €0.17 per GB-month for fast block disks, what does one copy cost per month in each?
  3. Singapore had a copy on each of 20 VM disks. What did that cost compared with one object-storage copy?
Step 2 · Complete

Finish Lina's block table

Design Practice

Lina's table matches StayHub workloads to building blocks. Two rows are blank. Fill in the block and a one-line reason.

WorkloadShapeBlockWhy
Booking APISteady, 200–900 req/sAlways-on VMs, autoscaledAlways busy; stateless replicas
Nightly report1.5 h a nightScheduled job on VMs created for the runExists only while running
Thumbnails for uploads~2,000 uploads a day, in bursts______
Bookings and payments dataQueried, transactional______
Hotel photosShared files, read worldwideObject storage + CDNOne copy, served near guests
Step 3 · Solve

Where should invoice PDFs run?

Design Practice

Every night, StayHub must generate about 6,000 invoice PDFs for partner hotels (one per hotel) and keep them for 10 years.

  • Each PDF takes about 1 s of CPU.
  • It must finish within 2 hours and retry failures.
  • Nothing runs during the day.
  • Hotels download their invoices from the extranet whenever they like.

Choose the compute, the storage and how hotels download the files. Estimate how many parallel workers you need.

Step 4 · Decide

Functions or containers for price alerts?

Decision Stretch

Maya wants a new feature: guests watch a hotel, and get a push notification when its price drops. Hotels' price updates arrive as events:

  • On a normal day about 2 million price events, but 90% arrive between 06:00 and 08:00 when partner systems sync; the rest of the day is nearly idle.
  • Each event takes about 30 ms to check against watchers.
  • A notification can arrive a few minutes late.

Options: A, serverless functions triggered by the events; B, containers running all day, autoscaled.

Write a short decision: "We chose X over Y because…, accepting the risk of…".

16

Explain it yourself

Explain to a new teammate why the booking API runs on always-on, autoscaled machines, thumbnails run in functions, photos live in object storage, and bookings live in a managed database.

0 words