RV·216
The Final Operating Model
The roadmap's end state: not knowing every technology, but reasoning through every layer, from "what should we build?" through requirements, architecture, frontend, backend and AI, data, distributed behaviour, security, testing, deployment, operations, performance and cost, failure and evolution; the layers walked top-down for a new feature and bottom-up for an incident; the final principle's chain from user action to incident with what happens, why, how it fails, how to measure it and how to improve it at each step; with a lab that times one real request through DNS, TCP, TLS, a proxy, an API, Redis, a database transaction, an outbox relay and a worker.
Start here: reasoning through layers
The roadmap ends with a picture rather than a list:
WHAT SHOULD WE BUILD?
↓
PRODUCT / REQUIREMENTS
↓
SYSTEM REQUIREMENTS
↓
ARCHITECTURE
↓
┌────────────────┼────────────────┐
↓ ↓ ↓
FRONTEND BACKEND AI
│ │ │
└────────────────┼────────────────┘
↓
DATA MODEL
↓
DISTRIBUTED BEHAVIOR
↓
SECURITY / IDENTITY
↓
TESTING / VALIDATION
↓
DEPLOYMENT
↓
OBSERVABILITY / SRE
↓
PERFORMANCE / COST
↓
FAILURE / DR
↓
EVOLUTION
A strong engineer can enter at any layer and reason upward and downward. Entering at the top means designing: a product question flows down into requirements, architecture and code. Entering at the bottom means operating: an alert or a cost spike flows up to the layer that caused it and the requirement it threatens. Entering in the middle (a slow query, a confusing API) means asking both: what does this serve above, and what does it rest on below?
One request, timed through the layers
The lab sent "skip 10 November" through a small but complete stack on one machine (HTTPS through nginx, a Python API, a Redis session, a PostgreSQL transaction with an outbox row, a relay, a worker):
| Step | Time (median) |
|---|---|
| name lookup (hosts file) | 0.01 ms |
| TCP connect | 0.07 ms |
| TLS handshake (ECDSA) | 2.09 ms |
| request → first byte of the response | 2.03 ms |
| …of which in the API: session lookup in Redis | 0.17 ms |
| …SQL: lock subscription, idempotency key, skip, outbox row | 0.69 ms |
| …commit (write-ahead log flushed) | 0.35 ms |
| total, new connection | 4.26 ms |
| total on a reused connection | ~1.2–2.2 ms |
| commit → event published by the relay (polling every 50 ms) | 31 ms |
| published → worker received it | 0.36 ms |
On one machine, the TLS handshake was the single biggest cost of a new connection, and the asynchronous part took ~15× longer than the synchronous request, because of a polling interval nobody would notice until they looked. In production, add 20–60 ms per network round trip from a phone to the region (three round trips for a new HTTPS connection before the response arrives), and DNS misses of tens of milliseconds.
How deep to go
Volume 17 defines six mastery levels. The operating model is L5–L6 by definition: designing across layers and running the result. The way there is L3–L4 in every layer of the chain below, so that nothing in it is a black box to you.
Top-down: designing a feature through every layer
Take gift subscriptions for TiffinBox: a customer buys a month of lunches for someone else.
| Layer | Questions to answer |
|---|---|
| what should we build? | who wants this (festivals, new parents)? how will we know it worked (gifts sold, redemption rate, retention of recipients)? |
| product / requirements | buy, send, redeem flows; what if the recipient's area has no kitchen? refunds? |
| system requirements | payment exactly once; codes unguessable; redemption within 30 days; email delivery within 5 minutes; checkout p95 < 800 ms |
| architecture | Payments and Subscriptions modules; a GiftPurchased event; no new service |
| frontend | gift form (accessible, mobile-first), shareable redemption link with the code in the URL fragment, not the query |
| backend | use cases with idempotency keys; redemption as a transaction that marks the gift used and creates the subscription |
| AI | the assistant can answer "how do I redeem?" from help docs; no tool may redeem on someone's behalf |
| data model | gifts(code_hash, buyer, amount, expires_at, redeemed_by, redeemed_at) with a unique constraint and a partial index on unredeemed |
| distributed behaviour | events for email and analytics; consumers idempotent; email retries with the event ID |
| security / identity | codes with 128 bits of randomness, stored hashed; rate-limit redemption attempts; audit refunds |
| testing / validation | concurrent double redemption test; contract test for the event; E2E for buy → redeem |
| deployment | behind a feature flag; canary; expand-only migration |
| observability / SRE | SLIs for checkout and redemption; dashboard; alert on redemption failures |
| performance / cost | negligible load; email provider cost per gift |
| failure / DR | payment provider down during checkout; email provider down; what the buyer sees |
| evolution | corporate bulk gifts later: keep buyer as an account, not a person |
Twenty minutes of this table prevents weeks of rework.
Bottom-up: reasoning from an incident
At 10:20 an alert fires: the skip API's error budget is burning at 20×. Reason upward and downward:
- Observability: errors are
503from the API, only onPOST /skips; latency for other endpoints is normal. - Down a layer (backend): traces show the skip use case waiting ~3 s on the database pool, then failing; other use cases get connections.
- Down (data):
pg_stat_activityshows many sessions waiting on a row lock onsubscriptions; one long transaction holds it. - Down (distributed behaviour): the long transaction is a worker processing a backlog of
MenuChangedevents, and its code calls the email provider inside the transaction; the provider is slow today. - Up (impact): customers can't skip before the 10:30 cut-off; kitchens will cook unwanted lunches; refunds will follow.
- Mitigate: pause the worker; locks release; skips succeed; extend the cut-off by 15 minutes for affected kitchens (a product decision, made quickly).
- Prevent: no remote calls inside transactions; a lock timeout; a bulkhead for the worker's pool; an alert on lock waits; a test that fails if a transaction spans an HTTP call.
The incident started in one layer and was caused three layers away; only reasoning across them finds it.
The final principle, layer by layer
The roadmap's closing chain, with the five questions for each step (what happens, why, how it fails, how to measure it, how to improve it):
| Step | What happens and why | How it fails | How to measure | How to improve |
|---|---|---|---|---|
| user action | a tap becomes an event handler, state update and request | long tasks block input; double taps | INP, error tracking | yield, debounce, idempotency keys |
| browser | resolves, connects, sends; renders the response | slow DNS, blocked rendering, CORS | RUM timings, Web Vitals | preconnect, caching, smaller JS |
| HTTP | request and response over a connection (HTTP/2 or 3) | timeouts, retries of unsafe methods | status codes, latency per route | correct semantics, keep-alive, conditional requests |
| load balancer | terminates TLS, routes to a healthy backend | uneven load, draining errors, connection limits | backend health, 5xx at the edge | readiness, draining, limits |
| service | parses, authenticates, validates, runs a use case | pool exhaustion, slow dependencies | RED metrics, traces | timeouts, bulkheads, breakers |
| thread / virtual thread | runs the handler; blocks on I/O | pinning, unbounded concurrency, contention | thread dumps, JFR | virtual threads with limits, fewer locks |
| transaction | groups reads and writes atomically, isolated to a level | lost updates, deadlocks, long locks | lock waits, deadlock counts | atomic updates, right isolation, short transactions |
| database / index / WAL | finds rows through indexes; WAL makes commits durable | bad plans, bloat, fsync latency, replica lag | EXPLAIN, pg_stat_statements, WAL metrics | indexes, statistics, vacuum, hardware |
| Kafka / event | outbox row published to a partition, retained | relay stalls, consumer lag, poison events | outbox age, lag, DLQ size | idempotent consumers, DLQ, scaling |
| worker | consumes, applies effects idempotently | duplicates, ordering bugs, retry storms | processing time, retries, duplicates | dedupe, per-key order, budgets |
| cache | serves copies; invalidated by events or TTL | stale or wrong data, stampedes, outages | hit rate, staleness, errors | TTL + events, locks, fallback |
| AI model / tool | retrieves context, generates, calls tools | hallucination, injection, outages, cost spikes | eval scores, abstentions, cost, latency | grounding, allow-lists, fallbacks, budgets |
| Kubernetes | schedules pods, restarts failures, rolls out versions | throttling, OOM kills, bad probes | restarts, throttling, events | right requests, probes, PDBs |
| cloud network | routes between zones and services | zone loss, NAT limits, misconfiguration | flow logs, synthetic checks | multi-zone, private endpoints |
| telemetry | traces, metrics, logs describe what happened | missing context, cardinality explosions | coverage of journeys | OpenTelemetry everywhere, low-cardinality labels |
| alert | burn rate crosses a threshold; someone is paged | noise, missing alerts | pages per week, missed incidents | SLO-based alerts with runbooks |
| incident | people detect, mitigate, recover, prevent | confusion, slow mitigation, repeat incidents | time to detect and mitigate | roles, runbooks, drills, postmortems |
When every row is something you can explain, measure and improve, you've reached the objective the roadmap set: not the number of technologies you know, but the number of layers you can reason through.
Lab: one request through every layer, timed
Setup. On the lab machine (2 CPUs):
- nginx terminating TLS (ECDSA P-256 certificate, TLS 1.3, no session resumption) and proxying with keep-alive to
- a FastAPI endpoint
POST /subscriptions/{id}/skipsthat: parses the JSON body; reads the session from Redis; takes a pooled PostgreSQL connection; in one transaction, locks the subscription row (FOR UPDATE) and checks ownership, inserts the idempotency key, inserts the skip, inserts an outbox row; commits; reports each step in aServer-Timingheader; - a relay polling the outbox every 50 ms and publishing to a Redis Stream (standing in for Kafka);
- a worker blocking on the stream and recording when each event arrived.
curl measured the client side (time_namelookup, time_connect, time_appconnect, time_starttransfer, time_total); 20 requests on new connections and 10 on one reused connection.
Results
| Client-side step (new connection, median of 20) | Time |
|---|---|
name lookup (localhost, from the hosts file) |
0.01 ms |
| TCP handshake | 0.07 ms |
| TLS handshake | 2.09 ms |
| request sent → first byte back | 2.03 ms |
| total | 4.26 ms |
| total on a reused connection | 1.2–2.2 ms |
| Inside the API (median of 20) | Time |
|---|---|
| parse body | 0.02 ms |
| session lookup in Redis | 0.17 ms |
| get a pooled connection | 0.01 ms |
| 4 SQL statements (lock + ownership, idempotency key, skip, outbox) | 0.69 ms |
| commit | 0.35 ms |
| sum | 1.24 ms (the other ~0.8 ms of "first byte": proxy, HTTP framing, Python overhead) |
| After the response (20 events) | Median | Max |
|---|---|---|
| commit → relay published | 31.2 ms | 54.2 ms |
| published → worker received | 0.36 ms | — |
| commit → worker received | 31.8 ms | — |
What it shows
- Every layer is visible if you instrument it. Two headers' worth of timing (
curl -wandServer-Timing) accounted for the whole request. - Connection setup dominated on a new connection: the TLS handshake alone took as long as the entire request-and-response. Reuse connections everywhere.
- The database work was under a millisecond for a transaction with a row lock, three inserts and a durable commit, a reminder that most latency in real systems comes from waiting (network, queues, locks), not from work.
- The asynchronous path was the slowest (~31 ms) purely because of a polling interval; that's acceptable for kitchen counts and emails, and a deliberate design choice once you've measured it.
- What one machine hides: network round trips. From a phone to a cloud region, multiply each of DNS (when not cached), TCP, TLS and the request by 20–60 ms; a new connection then costs ~100–200 ms before the server does any work, while the work itself stays ~1–2 ms.
Try it yourself
- Turn on TLS session resumption in nginx and measure the handshake again with a client that resumes.
- Replace the relay's polling with PostgreSQL
LISTEN/NOTIFY(notify on outbox insert) and measure commit → published. - Add OpenTelemetry to the API, relay and worker with context in the outbox row and stream message, and view the whole path as one trace.
- Add 30 ms of artificial delay to each client round trip (a proxy that sleeps) and recompute the new-connection total.
Revision sheet: the final operating model
Key ideas
- The goal is reasoning through layers, not collecting technologies.
- Top-down for design: product → requirements → architecture → … → evolution.
- Bottom-up for incidents: symptom → cause in lower layers → impact in higher layers.
- For every step of a request: what happens, why, how it fails, how to measure, how to improve.
Numbers to remember
- Lab: TLS handshake ~2.1 ms (largest connection cost locally); API work ~1.2 ms; new connection total ~4.3 ms; reused ~1.2–2.2 ms; outbox relay ~31 ms (50 ms polling).
- New HTTPS connection: ≥ 3 round trips (TCP, TLS 1.3, request), plus DNS if uncached; 20–60 ms each on mobile.
Glossary
- Operating model: the layered way of reasoning about a system from purpose to evolution.
- Server-Timing: an HTTP header reporting server-side timing breakdowns.
- Round trip (RTT): time for a message to go to a peer and back.
- Polling interval: how often a loop checks for new work; sets a floor on reaction time.