The catch
Salespeople skip this slide, so here it is. When an event arrives and no copy of your function is warm, AWS must create one: provision a micro-VM, load your code, start the runtime. That pause is a cold start, and the request that triggered it waits through all of it: commonly 100 to 1000 ms, worse for big deployment packages and heavy runtimes, and it happens again per concurrent copy when traffic jumps.
After the run, AWS keeps the copy warm for a while, so the next event skips the pause. Under steady traffic most invocations are warm, and cold starts hide in the slowest fraction of requests, which is exactly where users notice them. Engineers measure that slow fraction with percentiles: sort all response times, and p99 is the value that 99% of requests come in under, leaving only the slowest 1% above it. A cold start barely moves the average, but it shows up instantly at p99, which is why latency budgets are usually written as percentiles, not averages.
Honest guidance: for background jobs and pipelines like lesson 7-2's thumbnails, cold starts are irrelevant. For latency-sensitive user-facing APIs, they are a real cost you weigh against never patching a server, and mitigations (like paying for pre-warmed capacity) exist but cancel some of the savings.
Code exercise · bash
Watch one cold start hide from the median and own the tail. Ten requests hit a function; one of them (812 ms) paid the cold start. Run it: with only 10 samples the sorted list's 5th value is the median (p50) and the 10th is the worst case, the small-scale stand-in for p99.
Code exercise · bash
How much do cold starts hurt on average? If 2 of every 100 requests hit an 800 ms cold start and the rest take 15 ms, run the weighted average (computed in integer math, printed with two decimals).
Code exercise · bash
Your turn. A heavier function cold-starts in 1200 ms, runs warm in 20 ms, and after a marketing push 5 of every 100 requests are cold. Update the three variables and compute the new average.
Quiz
Which workload should worry LEAST about cold starts?