Three things broke, and none of them was the model
For the past few months, outside of work, I've been building personal projects meant to teach, me first and then whoever reads the code: small systems about performance, AI, optimization and good engineering practices, each one with its numbers written down and its tests in the repo. Three of them show up a lot in this post. ticketmesh is a ticketing backend for the minute a show goes on sale, ledger is a payments ledger where money can't move twice, and CodeSentry Swarm is a set of agents that review pull requests. None of them is a company's production system. They're where I test, on purpose and with measurements, the ideas I bring to the teams I work with.
Before my talk at Universidad Indoamérica, I deployed CodeSentry to Google Cloud for the demo. It's three agents that read a pull request, try to prove the bug with a failing test inside a sandbox with no network, and comment a fix. A person still merges, and deterministic code makes the final call.
I expected the models to be the hard part. They weren't. The first rollout broke in three places no test double had caught: an Eventarc trigger kept answering 403 while permissions were still propagating, Terraform quietly wiped a field off the Cloud Run job, and the trace split in two. The third one is the one that matters for this post. The traceparent wasn't traveling on the message, so the result that came back through Eventarc opened a brand-new trace, and the second half of the work simply disappeared from view.
None of that is about AI. It's about where work lives, and whether you can still see it when it moves. When I gave the talk on November 13, 2026, De APIs REST a Sistemas Autónomos, most questions were about the models. What I really wanted people to take home was older than any model:
A web system is ready for the next feature when someone has already decided where each kind of work is allowed to live, and written down the number that says whether that decision still holds.
An agent, a new screen, a payment provider. Drop it inside a request you already proved and you'll end up rebuilding that path. Put it behind a boundary and the path that already worked keeps working. This post is how I make that call, on the backend and on the page, and how I let a percentile settle the argument instead of a hunch.
Two companies, the same gap
I've kept very large distributed systems running in companies that were already far along. A request came in at the edge and left with a trace id. Monitoring, traces and logs were designed flows, not a folder someone opened after the incident. Every metric had an owner. When something got slow, the percentile and the trace pointed at the service, and nobody had to guess.
I've also worked in companies that were growing and missing exactly that. The product worked fine. But the next step (more users, a new payment method, a feature that calls a model) kept stalling, because nobody could say which part of the path had gotten slow. There was a log file and a feeling.
The practices were the same in both places. What changed was timing. In the mature company, that floor was simply how you kept moving. In the growing one, building it turned out to be the step before the feature they actually wanted to announce. Without a trace that crosses services, a p95 written down somewhere and someone watching saturation, every new feature is a bet.
Where the work goes
When a feature lands on my desk, the first question isn't which framework to use. It's which of four places the work belongs in.
REST, when the client knows what it wants. Create a hold, fetch an order, update a profile. One name, one action, a latency you can budget and a response you can cache. This is where I start, and honestly, most web backends should stay here longer than they do. A stable resource is easy to test, easy to document and easy to put a deadline on.
GraphQL, when the screen is the client. A dashboard that ends up firing six REST calls, fetching too much on a phone and too little on a desktop, has a view problem, and GraphQL lets that view ask for the shape it needs. What it isn't is a reward for picking something newer. I've turned down "let's use GraphQL, it's modern" in design reviews, and the question is always the same: is that flexibility worth what the team will have to maintain? If the screen is stable and the resources are obvious, REST is cheaper to own.
Events, when more than the caller cares that something happened. ticketmesh is the clearest example. When a show goes on sale, thousands of people want the same seats, and each seat can be sold exactly once, across seven services in Go, Python and TypeScript. The hold stays synchronous, one conditional update in Postgres, because two buyers can't both win. The payment is a different story. Charging a card and telling the buyer aren't one transaction, so that part is a saga: each producer writes an outbox in the same transaction as its own change, each consumer keeps an inbox, retries back off, and a dead letter catches whatever never lands. The buyer finds out over a WebSocket. The HTTP request that started it all was never going to be where all of that finished.
A queue, when you don't know how long it'll take. This was the first pattern in the talk, and it's the one I'd like every web team to have before adding anything that "thinks". The client posts, the API answers 202 with a task id, the work goes on a bus, and progress comes back over server-sent events. Nobody holds a worker hostage while a model, a transcode or a report runs.
The reason is the contract. A normal request promises one input, one output and a time you can predict. A loop that reasons, acts and checks the result promises none of those. The number of turns sets both the latency and the bill, and you don't know it up front. Put that loop on the request path and the proxy cuts it, the worker pool starves, a retry charges you twice, and the page that was fast last week is slow because of a feature that isn't even on screen yet.
"At least once" also means twice on a bad day. In CodeSentry the task id comes from the work, not from the delivery: repo, pull request and commit. A second webhook for the same commit finds the claim already taken and does nothing. Transient failures (timeouts, 429s, 5xx) release the claim so the bus can retry with backoff, and after a fixed number of deliveries the message lands in a dead letter. Terminal failures don't retry at all: the budget ran out, the schema broke twice, three iterations produced no fix. Retrying those is just spending money in a circle, so a person takes the task.
The platform already has opinions
This is where infrastructure stops being someone else's job. On Cloud Run a request waits 5 minutes by default, with a ceiling of 60. A Pub/Sub push subscription acks within 600 seconds at most. People love quoting the load balancer's 30-second default backend timeout at me, but on Cloud Run, behind a serverless network endpoint group, that isn't the limit that applies: the request can run the full hour. Which is still no reason to block a worker for an hour.
The same goes for how events get consumed. On Cloud Run I use Pub/Sub push, not a worker sitting on a pull subscription, because services scale to zero and a pull consumer dies with its instance. Get that wrong and the diagram says "event-driven" while production says "always on, just in case". If nobody on the team knows which limit is the real one, the architecture diagram is fiction.
Averages lie
If nine requests take 20 ms and one takes 2 seconds, the average looks healthy. The tenth user would disagree.
I follow what Google's SRE book recommends: treat latency as a distribution, and watch four signals together, which are latency, traffic, errors and saturation. A percentile on its own will happily congratulate you for getting faster by failing the slow requests. Saturation is how you see the wall before the percentile hits it.
Each percentile answers a different question for me:
- p50 is the typical request. It shows me the happy path, and it's far too kind to ship on.
- p90 is what I watch while I'm still building, before there's enough traffic for a stable tail. It already shows what the median hides.
- p95 is the line I usually write into the SLO of a user-facing API: ninety-five calls out of a hundred, under a number the product can defend.
- p99 is the tail I still owe people. One in a hundred sounds small until it's a ticket sale. It's also where lock contention, cold starts, retry storms and garbage-collection pauses show up.
p99.9 earns its place when one screen calls many services, because tails multiply: a page that talks to ten backends, each one "fine" on average, is slow for far more than one percent of users. I don't launch a product demanding p99.9, but I do push back on any dashboard that only shows the mean.
One more thing gets mixed up all the time. For an API, the SLO lives on the server's p95 or p99. For the page, the bar is Core Web Vitals, and Google scores those on field data at the 75th percentile: largest contentful paint within 2.5 seconds, interaction to next paint within 200 ms, cumulative layout shift at 0.1 or less. A fast API can still miss INP if the main thread is busy, and a lovely LCP can hide an API whose p99 is a timeout. I measure both, and I don't let one stand in for the other.
Letting a number say no
On ticketmesh we wrote the rule before running the test: Redis would only go in if 200 holds a second pushed the p99 past 300 ms. The run came back at 3.59 ms p99, zero errors over 60 seconds, with Postgres sitting at 21% CPU. Redis stayed out. That was measured on a laptop, and the free cloud VM is smaller, so the same test still has to run there before a real sale. But the rule did its job: a new component had to beat a number, not a mood.
It works in the other direction too. ledger is a double-entry payments ledger in Go and Postgres, where each transfer posts once per idempotency key, so a retry never moves money twice. The median post across 1,000 accounts with 8 clients was 2.4 ms. When 32 clients fought over 10 hot accounts, more concurrency bought no extra throughput and the p99 jumped to 207 ms. The locks were correct. They were also the ceiling. Without the percentile, I would have "fixed" it by adding more clients.
Then there's CodeSentry, measured on real Google Cloud on November 4, 2026, with three pull requests: the fastest finished in 106 seconds, the slowest in 262, the most expensive cost $0.016, and one trace held 15 spans. Three pull requests are an anecdote, not a benchmark, and I said so in the talk. What they were good for was showing where the time went. The model answered in seconds; waiting for the Cloud Run job dominated the trace. So the next optimization is the job's startup, not a smarter prompt.
That trace only told the truth once I fixed the split from the beginning of this post: the traceparent travels on the message, and it's stored before the sandbox starts. A path you can't see end to end is a path you shouldn't extend. I wrote about the tooling in Observability When Code Ships Faster Than You Can Read It. The rule here is stricter than any tool: no new step on a path whose tail you can't plot.
Tests that guard the number
A unit test has no idea what your p99 is. I keep the other layers apart because each one answers a different question, and blurring them is how a suite gets slower without getting any more honest.
- Integration tests check two real pieces and the contract between them: the idempotency claim, the webhook signature, the schema a model has to satisfy. Deliver the message twice and prove the side effect happened once. That's the test that protects the queue.
- End-to-end tests follow a path a person actually takes, in a browser or against the deployed API. Keep them few, and put them on the flows that move money or trust. They're a poor place to discover that the p99 moved.
- Load tests run the traffic you promised, for long enough to mean it. ticketmesh's line was 200 holds a second for 60 seconds, and a heavier run held 600 a second with zero failures across 109,497 requests. Passing means the SLO held and errors stayed at zero, not "it didn't crash".
- Stress tests go past the promise on purpose, to find out what bends first: the pool, the lock or the budget.
- Soak tests catch the bugs that need time, like a leaking pool or a token that dies at minute forty. A five-minute load test will applaud a system that falls over at hour two.
Next to every critical path, before the feature, I want a contract short enough to fit in a test name:
hold: p99 < 300ms at 200/s for 60s, 0 errors, k6 owns it
A new feature either fits that contract or doesn't ship on that path. That's what "don't build a bottleneck" means in practice: unbounded work gets its own queue, its own budget and its own number. It doesn't get to live inside the hold.
And as the rollout at the top of this post showed, test doubles won't save the deploy. Load tests and a real deploy do different jobs, and you need both before your users are the ones who find the tail.
When a model shows up on the page
The page already had a budget. A model just spends it in new ways: a reply that keeps going, a component nobody designed, a main thread busy painting tokens. Core Web Vitals are still the bar. What changes is where the slowness comes from, and a few habits keep it in check:
- Keep generation off the first paint. The HTML people see first comes from the server, the page you already measured. The agent panel is a client island that starts empty. If the model sits on the path to the largest paint, the budget is gone before anyone reads the title.
- Show long work as state. Queued, running, done, arriving over server-sent events or a small read of the task id. The button starts the job and the page stays responsive. A spinner that blocks hydration is an interaction you gave away.
- One request per view. Six fetches in a row blow the interaction budget even when each looks fast on average. If the screen needs a shape the resources don't have, give it a small backend for that screen, or GraphQL, and stop the waterfall.
- Don't let tokens grow the DOM forever. Virtualize long replies or collapse them as they grow. Otherwise your 75th-percentile interaction ends up tracking the length of the text instead of your code.
- Don't cache what the model just made up. Cache the page, the images, the fonts and the next route. A generation is a side effect; caching it is a bug, and a bill you pay twice.
- Generated components join the design system, or they don't ship. A button the model invented, with its own CSS and its own fetch, throws away performance work you already measured. A typed client makes a contract change fail the build instead of failing a user. I reworked this site once without that discipline and once with it, and I wrote up the second time in Your Portfolio Speaks Before You Do.
Who makes the call
None of this gets decided by a framework or a ticket. Someone on the team has to look at a feature and say where it goes, what it's allowed to wait on, and what would make them reverse the decision later. I do that as part of designing the system, not as a title I wait to be handed.
That person needs enough infrastructure to know what the platform will cut, kill or bill, enough monitoring to see a distribution instead of a vibe, and the standing to say "this goes on the queue" or "we're not adding Redis". With new tools showing up every few months, that role matters more, not less. The shiny new feature is often unbounded (an unknown number of steps, a cost on each one, code you didn't write), and dropped into the request that renders the page, it becomes a bottleneck built out of enthusiasm.
Next to that person I want someone who came up through security, or is studying it right now. The systems coming next will have queues, agents, code nobody wrote by hand and data crossing several services, and the feature that doesn't fit in a request is usually the one running code you didn't write, on a budget nobody capped. Reading the percentile and reading the attack turn out to be the same conversation: what is this feature allowed to do, with which credentials, and what happens if it runs twice? If you're studying cybersecurity engineering, that seat already exists on the teams that ship product, and we need more people in it. I wrote about that side in AI and Security: The Same Tool on Both Sides.
Limits are also how you control cost. CodeSentry stops a task at 20,000 tokens and three iterations, then hands it to a person. A circuit breaker stops calling the main model after repeated failures and falls back to a smaller one. Pull requests from forks are ignored, because a public repo shouldn't be an open tab. Without those limits, an agent that "almost" has the answer will happily spend the afternoon confirming it.
Maintenance is the quieter win. An idempotent consumer, a schema at the boundary and a trace that crosses the queue mean the next person can change one stage without re-proving the whole path. I've split a payment into events when the request couldn't hold it, and I've folded services back together when the split wasn't earning its latency. Both times the percentile was the argument, and both times the work that was already green stayed green.
The one thing to take home
New things will keep arriving: a model, a protocol, a client that wants a different shape. A system that already knows its p95, its p99 and which work is allowed to be slow can take them one at a time, and the work you already validated stays where it is.
So if you take one thing from the talk back to an ordinary web codebase, take the contract. Write down the percentile and the line before you build the feature. Then let that number say no.
References and further reading
- The talk, "De APIs REST a Sistemas Autónomos" (Universidad Indoamérica, November 13, 2026). listerineh.dev/slides/agents-backend-gcp
- CodeSentry Swarm and the demo shop the traces came from. github.com/listerineh/codesentry-swarm · github.com/listerineh/codesentry-demo-shop
- Cloud Run request timeouts, Pub/Sub ack deadlines, backend service timeouts. Cloud Run · Pub/Sub · Load balancing
- Google SRE book, monitoring distributed systems: latency as a distribution, and the four signals. sre.google
- Core Web Vitals, including the 75th-percentile field thresholds. web.dev/articles/vitals
- The security half of this, written earlier. AI and Security: The Same Tool on Both Sides
What did you think?
Found this article helpful? Share it!
Help others discover this content by sharing it on your favorite platform.



