Containers and serverless
After today, you can explain what containers, Kubernetes, and serverless functions are for, and why serverless code sometimes starts slowly.
Dip your toes 1 min
In a simplified picture of Instagram, posting a photo leaves a job waiting in line to resize it into a thumbnail and larger versions. Something still has to run that job. Containers and serverless are two ways to run code like it. A container is a sealed package holding the code plus everything it needs, like the right language version and tools. It runs the same way on a laptop and in the cloud. Serverless means handing a cloud company a small piece of code and paying only when it runs, such as when a photo arrives. Code that hasn’t run lately takes extra time to wake up, called a cold start. So the first person to open a rarely used screen can wait an extra second, and the next person doesn’t.
The full lesson 10 min
Why this exists
Day 18 left a resize job in Instagram’s queue. Something has to run it. Running any code, on any machine, raises two problems.
Every engineer has heard “it works on my machine.” Code never runs alone. It needs a runtime of the right version, the libraries it was written against, system tools, and settings. A laptop has one combination of all that, a test server another, and a production server a third. Small differences between them cause bugs that only appear in one place, and those take days to find.
The second problem is idle machines. In a simplified version, that resize job turns each photo into several versions, such as a thumbnail, a feed size, and a full size. Uploads come in waves, heavy in the evening and light at night. A team that keeps enough servers running for the evening peak pays for most of them to sit still the rest of the day.
Containers address the first problem: they make code carry its environment with it. Serverless addresses the second: it runs code only when there’s work, and charges only for that. Serverless is a higher rung on Day 22’s ladder. A container is a package that can run on any rung.
What it is
Start with the virtual machine, the basic rental unit of the cloud. A virtual machine is software that acts like a complete computer, with its own operating system, running alongside others on one physical machine. It’s flexible, and it’s heavy. Each one carries a whole operating system, takes a while to start, and needs updates and care like a real computer.
A container is lighter. It’s a package holding an app and everything the app needs to run: the runtime, the libraries, system tools, and settings. Containers on one machine share that machine’s operating system core, so they start in seconds and dozens can fit where a few virtual machines would. Docker, released in 2013, made containers practical, and its name is now shorthand for the whole idea.
The package is built from a short recipe file called a Dockerfile. Here’s what one might look like for the photo resizer:
FROM python:3.12-slim
RUN pip install pillow
COPY resize.py /app/
CMD ["python", "/app/resize.py"]
Read it from the top. Start from a small Linux system with Python already installed. Add Pillow, a popular library for editing images. Copy in the team’s resizing code, then say which command to run when the container starts.
Building that recipe produces an image, a sealed package, stored as a stack of layers. Most lines add a layer: a base system, the image library, then the team’s code. Running the image starts a container. The same image runs on an engineer’s laptop, in the automated checks, and in production, so all three run exactly the same thing.
One container is easy. A large product runs thousands of them across hundreds of machines, and they crash, get overloaded, and need replacing. Something has to decide which machine runs each container, restart the ones that fail, and add copies when traffic grows. That job is called orchestration, and the standard tool for it is Kubernetes.
Kubernetes is an open-source system that runs containers across many machines. Google open sourced it in 2014, drawing on its long experience running its own services. The name is Greek for helmsman, and engineers often write it as K8s. You don’t tell Kubernetes what to do step by step. You describe the state you want, such as three copies of the resize worker, and Kubernetes keeps reality matching it.
Teams often let a cloud provider run much of Kubernetes for them. The big cloud providers each offer a managed version: Google Kubernetes Engine, Amazon EKS, and Azure Kubernetes Service. Even so, Kubernetes is a large system with its own vocabulary and its own specialists.
Many teams have a platform group whose main job is keeping it healthy for everyone else. For a small team, that overhead can outweigh the benefits. Many start on a full platform or on serverless, and move to Kubernetes only when they outgrow it.
Serverless goes one rung higher. You hand the provider a function, a small piece of code that does one job, and say which event should trigger it. When a photo lands in storage, the provider finds a machine, runs the function, and bills you for that run. When no photos arrive, nothing runs and nothing is billed. AWS Lambda, Google Cloud Run functions, and Vercel Functions all work this way.
The resize job shows the appeal. A thousand uploads at once means a thousand runs in parallel, without anyone adding servers. A quiet night costs almost nothing.
The trade is control. You can’t pick the machine or keep a process running between requests. Each run also has time and memory limits. A job that takes an hour, like processing a long video, may not fit in a single function at all.
Serverless also changes how a team thinks about cost. A function that runs a million times a month is billed for a million short runs, not for a server that sat waiting. That’s cheap for spiky, light work and can get expensive for steady, heavy work. Teams often mix the two: always-running containers for the main app, and functions for jobs that come in bursts.
How it shows up in your work
In a planning meeting, someone says the feature would need a new service. Today, that usually means a new container to build, configure, run, watch, and pay for. Or it means a new serverless function, which is cheaper to start but has its own limits. Either way, a new backend piece is ongoing work, not a one-time task. The real choice is how much of that work the team keeps for itself.
Notice that containers by themselves don’t move much work off your team. The image still has to be built, and the machines under it still have to be run. Orchestration and managed services are what shift the work. When an engineer argues for one option over another, they’re usually arguing about which column the team wants to own.
Serverless timing also reaches the upload screen. With serverless resizing, the full-size photo may be saved a moment before its smaller versions exist. A feed that asks for the thumbnail too early gets nothing back.
That gap is the same kind of delay Day 18 covered, and it needs a design. Options include a blurred placeholder, the full image scaled down for a moment, or a short processing state. Ask how long the resize usually takes, and how long it takes on a bad day.
Containers can also show up on your own laptop. Many teams describe their whole local setup, app plus database plus helpers, as a set of containers. One command, often docker compose up, starts all of it. For a designer who wants to review a branch running locally, that’s the difference between an afternoon of setup and a few minutes. Ask whether your team has one, and whether someone can walk you through it once.
The one thing people get wrong
“Serverless” sounds like there are no servers. There are servers, plenty of them. They belong to the provider, which decides when to start them and when to put them away. Your function still runs on a real machine, in a real data center, with a runtime that has to load before your code can run.
That loading is a cold start: the delay when the platform has to set up a fresh environment before running code that hasn’t run recently. The provider finds a machine, downloads your code, starts the runtime, and runs your setup code. After that, the environment stays warm for a while, and the next request skips straight to your function. AWS’s Lambda documentation says cold starts typically hit under 1 percent of requests. It puts their length between under 100 milliseconds and over a second, and since August 2025, AWS bills for that setup time too.
One percent sounds small until you notice who gets it. Cold starts land on the first request after a quiet stretch. That might be the first visitor of the morning, a rarely used admin screen, or a feature with light traffic. For a background job like resizing, nobody notices an extra second. For a checkout button or a login screen, a sudden second of nothing feels broken.
Teams have ways around it. They keep busy paths on always-running containers, or pay the provider to keep some copies warm, which AWS calls provisioned concurrency. They also keep functions small, because less code to load means a shorter setup. When a screen is “sometimes slow for no reason,” a cold start is one of the first things an engineer will check. It’s worth knowing the phrase so you can describe the pattern you saw: slow once, then fast.
Ask an engineer this
“Which parts of our product run as serverless functions, and has a cold start ever shown up as a slow screen?”
Ask this when a screen feels slow only some of the time, or when a new feature is about to land on serverless. The engineer should be able to say which paths run as functions, which run on always-on servers, and why. Check whether anyone has measured cold starts on a user-facing screen, or whether it’s a guess. If the team keeps critical paths warm, ask which ones made the list. You’ll learn where your product trades a little speed for savings, and whether your screens sit on the cheap side of that trade.
Terms from today
- Virtual machine
- Software that acts like a complete computer with its own operating system, so one physical machine can run several separate ones at once.
- Container
- A package holding an app and everything it needs to run, such as its runtime, libraries, and settings, so it runs the same way on any machine.
- Kubernetes
- An open-source system that runs containers across many machines, restarting failed ones and adding copies to match what the team asked for.
- Serverless
- A way of running code where the provider starts machines only when requests or events arrive and bills per run, so the team manages no servers.
- Cold start
- The delay when a serverless platform has to set up a fresh environment before it can run code that hasn’t run recently.