InfrastructureLesson 2 of 410 min

Servers, containers, and serverless

Three levels of "how much of this do I want to be responsible for".

These three are not competing technologies so much as three points on one dial: how much of the machine you are personally responsible for.

Turning the dial
  1. A machine
    You rent a computer. You own the OS, updates, restarts, scaling. Total control, total responsibility.
  2. A container
    You ship your app plus its exact dependencies as one sealed unit. The host runs it. "Works on my machine" mostly dies here.
  3. Serverless
    You ship a function. Something else decides when to run it, how many copies to run, and when to throw them away.

That last clause is the practical rule. Serverless functions are disposable, so anything written to their local disk or held in a variable between requests can vanish without warning. State has to live somewhere designed to keep it: a database, a cache, object storage.

Serverless suits

  • Traffic that is spiky or unpredictable
  • Work that finishes quickly
  • Not wanting to think about capacity
  • Paying nothing when nobody visits

Serverless fights you when

  • You need long-running processes
  • You want to hold things in memory between requests
  • You have steady, heavy, predictable load
  • You need persistent connections to something

The names on the pricing pages

None of these three words is what any of it is called when you go to buy it. Vendors sell branded products, and a brand name does not announce which point on the dial it occupies. The mapping is short and worth having once.

  • A machine is sold as an instance or a virtual machine: AWS EC2, Google Compute Engine, Azure Virtual Machines, a DigitalOcean droplet, a rented box from Hetzner.
  • A container is normally built with Docker, then handed to something that agrees to run containers for you: Kubernetes, AWS ECS and Fargate, Google Cloud Run, Fly.io.
  • Serverless is sold as functions: AWS Lambda, Azure Functions, Google Cloud Functions, Cloudflare Workers, and the functions built into Vercel and Netlify.

What to remember

  • The three options differ in how much of the machine you own.
  • Containers exist to make environments reproducible.
  • Serverless instances are disposable, so state must live elsewhere.

Terms in this lesson

Field notes

Loaded from a deliberately slow source. The lesson above was already readable while this was still travelling. That is streaming, and it is the same trick a chat interface uses.

The digest that stopped for five weeks

A weekly email job silently stopped running after an infrastructure change. Nobody noticed, because a job that does not run produces no error. It was discovered when a customer asked whether they had been unsubscribed.

Why you alert on missing success

Everyone retried at once

A service had a brief wobble. Every client retried immediately, then again, then again. The retries were far more traffic than the original load, and the service never got a quiet moment to recover. The outage lasted forty minutes longer than the fault did.

The thundering herd

resolved in 899ms · region iad1

Hide field notes toggles a search param the loader reads. With it off, the slow promise is never created, so nothing streams.