Ship without dropping a request
This is the capstone of the whole course. You've made the engine fast and routed, scaled, and packaged it — now you have to swap a live model out from under real traffic without anyone noticing, and finally put a price on every token.
The goal: zero downtime
A zero-downtime deployment ships a new version while the old one keeps serving, so no request is dropped and no user sees an error during the switch. The hard part is the in-between moment when both versions, or neither, could be holding a request.
Two outcomes you must control
A safe rollout watches the metrics that matter — P99 latency, error rate, and answer quality — and keeps a fast path back. If the new version regresses, you want an auto-rollback, not a 2 a.m. page.
Keywords — tap to unfold the plain meaning
Zero-downtime means swapping the live model with no dropped requests and no error spike — watch P99/errors/quality, and keep an instant rollback ready.
Three rollout plays
There are only three patterns to know, and they trade safety against how many replicas you have to run at once. Pick by how confident you are and how much spare capacity you can spend.
Blue-green
Blue-green: stand up a full new version (green) alongside the running one (blue), switch traffic over in one flip, and keep the old fleet idle as an instant rollback. Safest reversal, but you pay for two full fleets during the cutover.
Rolling
Rolling: replace replicas gradually, a few at a time, so the fleet is always a mix of old and new. Cheap on capacity, but rollback means rolling back the same slow way.
Canary
Canary: send a trickle of traffic to the new version — 1% → 5% → 25% → 100% — watching metrics at each step, with auto-rollback if P99 latency or error rate crosses a threshold. You catch a bad version while it's only hurting 1% of users.
Keywords — tap to unfold the plain meaning
Blue-green = one flip, instant rollback, double the fleet. Rolling = gradual, cheap. Canary = ramp 1/5/25/100% while watching, auto-rollback on regression.
The LLM catch: graceful drain
This is the one rollout detail that's special to LLMs. A web request finishes in milliseconds; an LLM answer can stream for many seconds. Pull the plug at the wrong moment and you cut someone's answer off mid-sentence.
Why it's different here
Generations can run for many seconds. If a rollout kills a replica mid-generation, those users get a truncated answer. A normal rolling update assumes requests end fast — that assumption breaks for token streaming.
The fix: drain, don't kill
Graceful drain: stop admitting new requests, let in-flight ones finish, then exit. The replica is told "you're going away" but gets time to finish what it's already streaming before it actually stops.
How Kubernetes does it
A preStop hook plus SIGTERM handling triggers the drain, and a drain timeout generous enough for the longest expected output lets it complete. Default terminationGracePeriodSeconds (30s) may be too short — size it to your longest generation.
Keywords — tap to unfold the plain meaning
preStop hook + long terminationGracePeriodSeconds (the 30s default may be too short for long generations). Size maxSurge/maxUnavailable around minutes-long weight-load readiness, and hook canary analysis to your TTFT / P99 SLOs. Omitted from the simple cost model but real: CPU/RAM, storage and model downloads, networking, idle and failed capacity, control-plane services, licenses, and temporary rollout surge.
LLM answers stream for seconds, so never kill mid-generation. Stop new requests, let in-flight ones finish, then exit — preStop + SIGTERM + a drain timeout sized to your longest output.
Cost per million tokens
Everything in this course was secretly about this one number. Make tokens cheaper and you do it by serving more tokens per second, or by keeping the fleet fuller. Here's the formula that turns GPU-hours into a price tag.
What "delivered goodput" means
Delivered goodput is the tokens per second you actually hand to users, not the peak the box can hit. It equals rated capacity × average utilization — the rated throughput discounted by how full the fleet really runs.
The double-counting trap
Do not count utilization twice. If tokens/sec came from observed production traffic, it's already a delivered rate — use it directly. If it's a saturation benchmark or rated per-GPU capacity, multiply by expected utilization to estimate delivery.
Math, decoded
- fleet $/hrtotal dollars per hour to run the whole fleet (e.g. $3 per GPU-hour × number of GPUs)
- Gdeldelivered goodput — tokens per second you actually deliver to users
- Cratedrated capacity — the aggregate tokens/sec the fleet can sustain at saturation
- Uaverage utilization — fraction of capacity actually used (e.g. 0.70 = 70%)
- × 3600seconds per hour: turns a per-second rate into tokens delivered per hour
- × 1e6scale the per-token cost up to a price per one million tokens
Take what the fleet costs per hour, divide by how many tokens it actually delivers per hour, then scale to a million tokens. Delivered goodput is rated capacity discounted by utilization — and you apply that discount exactly once.
Keywords — tap to unfold the plain meaning
$/1M = fleet $/hr ÷ (delivered goodput × 3600) × 1e6, and delivered goodput = rated capacity × utilization. Apply the utilization discount once — never twice.
The capstone: worked & checked
Two levers set the whole price, and one mistake can halve or inflate your estimate. Here's the capstone number, worked both ways so you never count utilization twice.
The two levers
Cost-per-token moves on exactly two dials. tokens/sec rises with quantization, batching, speculative decoding, and hardware selection. Utilization rises with routing, autoscaling, and replica load optimization. Every earlier lesson pushes one of these.
Worked example — rated capacity
Assume $3/GPU-hr, 2,000 aggregate tok/s rated, 70% utilization. Delivered goodput = 2,000 × 0.70 = 1,400 tok/s. Cost ≈ $0.60 / 1M delivered tokens.
The trap, made concrete
If that 2,000 tok/s was an observed delivered rate, it already includes utilization: $3 ÷ (2,000 × 3,600) × 1e6 ≈ $0.42. Do not multiply by 0.7 again — that double-counts the discount.
Capstone cost model — $3/GPU-hr · 2,000 tok/s rated · 70% util
Rated 2,000 tok/s × 0.70 utilization = 1,400 tok/s delivered → ≈ $0.60 / 1M tokens. If 2,000 was already observed-delivered, it's ≈ $0.42 — apply the 0.70 discount once.
The capstone formula, both readings
# rated capacity case (discount once): delivered = 2000 * 0.70 # = 1400 tok/s $/1M = 3 / (1400 * 3600) * 1e6 # ≈ $0.60 # observed delivered rate case (already discounted): $/1M = 3 / (2000 * 3600) * 1e6 # ≈ $0.42 (do NOT × 0.7 again)
Keywords — tap to unfold the plain meaning
Check yourself
- Name the three rollout plays, and which one ramps 1% → 5% → 25% → 100% with auto-rollback.
- Why is killing a replica mid-generation worse for an LLM than for a normal web service — and what three things implement the fix?
- Write the cost-per-million-tokens formula. Where does utilization enter, and what's the one mistake that doubles the discount?
- Finish it for a colleague: "We ship a new model with no downtime by…"
Canary or blue-green: ramp traffic while watching latency, errors, and quality; rollback on regression; drain in-flight generations within a measured grace budget. Then price the token — discounting utilization exactly once.