TL;DR
- In microservices the symptom usually shows up several services away from the cause. And the cause is a config mistake more often than a code bug.
- You can’t safely experiment on production, and a full copy of it costs an absurd amount. So we copy only the services that matter, and only when we need them.
- A small fine-tuned LLM does the part LLMs are great at, which is talking to the person who reported the problem. The diagnosis comes from tests, run in the right order.
When I was growing up in Kolkata money was tight, and there was always some pressure about it. Frugality was just how the house ran, so I picked it up without anybody sitting me down to teach it. You ask what you need before you spend, and you’re honest with yourself about what’s a need and what would only be nice to have.
I never thought of any of that as engineering. It took me years to notice that a lot of my research runs on the same habit, with computers in place of rupees.
A Kolkata tram
- Where
- BBD Bag terminus, Kolkata
- When
- April 2015
- By
- Gupsag1998
- License
- Public domain (CC0)
Before I got into research I worked in industry for years, on payment systems and data platforms. What stuck with me from the outages back then is that the service throwing the errors is almost never the one that’s broken.
Take a user who can’t check out. The errors are coming from the checkout service, so that’s where everybody looks. There’s nothing wrong with checkout, though. Its calls to payments are timing out, and payments is waiting on a database connection pool that somebody shrank in a config change two days ago. So the symptom shows up three hops away from the cause, and each hop has its own team, dashboards and alerts. My PhD research is on microservice diagnosis, and this pattern is what it’s about.
- Requests flow through the services.
- A config change shrinks payment-db’s connection pool.
- Errors climb back up, and the symptom shows at checkout.
- Only the suspects are copied into a partial twin, with mirrored traffic.
- Tests run in the twin, in order, and pin the cause.
Three reasons this is hard
- Failures cascade. One wrong setting (a stale cache TTL, a read from the wrong replica, an over-eager saga timeout) spreads through the dependency graph, and by the time anybody notices there are a dozen services that look unhealthy.
- You can’t experiment on production. The obvious thing is to say “let’s run some tests and see,” but in production that can corrupt real data, or fall over under real load. Most published work on diagnosis analyses logs offline, after the fact. I wanted something that runs online, while the problem is still going on.
- The report is vague, or just plain wrong. Real tickets say things like “the site is slow” or “my cart is empty,” and when the user does guess what’s wrong, sometimes the guess points in exactly the wrong direction.
Idea 1: a twin, but only part of one
A digital twin is a live copy of a system, one you can poke at as much as you like. A full twin of a large microservice application isn’t really practical, though, because you’d be paying for production twice.
The Apollo 13 “mailbox”
- Where
- Mission Control, Houston
- When
- April 1970
- By
- NASA
- License
- Public domain
So we build a partial digital twin. It’s a copy of only the most relevant services and data, and we create it on demand in a separate Kubernetes namespace. Istio replicates the services we selected and mirrors live traffic into the copies. That way the twin gets realistic requests, and production never sees the twin.
To decide which services get copied, we give every service a fault score. The score comes from three signals:
- its historical error rate,
- how often it’s called,
- and its place in the call graph of the failing transaction.
The twin starts out with the highest-scoring services. It only grows if the diagnosis needs more, and when it does it grows greedily, along the call graph. We keep the data small with stratified sampling and pre-aggregated tables, and there’s a cache in front.
We compared this with cloning the whole application. The twin used roughly 9 CPU cores instead of 32, 19 GB of memory instead of 128, and 142 GB of storage instead of about 1 TB. For me those numbers are what turn “diagnose in a sandbox” from a nice idea into something you’d run.
A full twin is a second production. A partial twin is a debugging tool.
This is the habit I grew up with in Kolkata, built into a system. The expensive answer to “how do we test safely?” is to copy everything (the expensive answer to most problems is to buy more). Being frugal about it means you work out which few things you need and copy those, and you only add more when the evidence says you should. That’s cheaper, which is nice. The part I care about more is that to decide what you need, you have to understand the problem first. If you copy everything you never have to do that thinking.
My favourite example is in the photo above, the Apollo 13 engineers. The crew needed a way to scrub carbon dioxide, and the engineers on the ground could only build it from what was already on board. That meant canisters, hoses, plastic bags, cardboard and tape. Having that little to work with didn’t slow them down, because it told them exactly where to look.
Idea 2: put the LLM where language is
This is the part I get asked about, and it’s the one I’d defend hardest. I see why it’s tempting to hand a large model the whole problem: here are the logs, here are the traces, tell me the root cause. I don’t trust that, and our experiments didn’t give me a reason to. A language model is excellent at the messy first step, though, the one where a person describes what went wrong. It can take “my cart keeps emptying itself” and turn it into a precise ticket you can test.
So triage is the only thing the model does. We fine-tuned a small open model (Mistral 7B, with LoRA and 4-bit quantization) to sort each complaint into one of eight fault classes. When it isn’t sure, it asks a follow-up question and doesn’t guess. It picks the question that separates the classes it’s torn between:
# roughly, in Python
turns = 0
while turns < 5:
label, confidence, probs = model.classify(conversation)
if confidence >= 0.8:
return ticket(label, conversation)
# torn between two classes? ask the question that splits them
question = model.ask(conversation, focus=top_two(probs))
conversation.append(user.reply(question))
turns += 1
return ticket(label, conversation, needs_human=True)
We cap the conversation at five turns. If the model still isn’t confident by then, the ticket says so and a human takes it. With fine-tuning, triage accuracy went from about 63% to 92%.
Most of the model’s mistakes were between classes that really are close to each other, which surprised me. It also turned out to be useful. When triage can’t decide between two neighbouring classes, the next step can run the tests that separate those two first, so fewer tests run overall.
Idea 3: tests, in the right order
Once there’s a ticket and a twin, the rest of the diagnosis is a search. We wrote 26 targeted tests and organised them by fault class. They go from “is the service reachable” to “does the database row match its cached copy.”
The order they run in matters a lot. We rank each test by how relevant it is to the ticket, and since the ranking works off embeddings of the test descriptions, a new test can be ranked without retraining anything. The plan runs the most likely tests first and stops as soon as one of them pins the root cause. It doesn’t grow the twin unless it runs out of tests.
We ran this on a 26-service shop built on Online Boutique, under realistic load. The median diagnosis needed only a little more than the ideal number of tests, within roughly 7 to 8 percent. In practice that was one or two extra tests.
The bugs that hide between services
Later work added tools for the failures I find most interesting. They come from patterns that are supposed to make a system faster.
- A saga analyzer takes the traces and rebuilds each distributed transaction as a state machine, then replays the timeouts and compensations. You get findings like “service X never received the compensating call,” and those can go straight to an engineer.
- Persistence probes check whether the cache, the database and the message queue agree with each other. They look at Redis TTLs and versions, database checksums, and Kafka offsets and duplicates.
What I took away
- Use the LLM at the edges. Language goes in and a structured ticket comes out. The reasoning that has to be right stays in code and tests, where you can inspect it.
- Copy less. Most of what “test it safely” costs goes on copying stuff that doesn’t matter. So the algorithm I find interesting is the one that picks what to copy.
- Run the likely tests first. I’d take the right three tests run first over all twenty-six run in parallel.
- Say what you didn’t do. I hold myself to this now, because overclaiming loses a reviewer’s trust faster than anything else I know of.
The honest limits
The work assumes one fault at a time. We also injected the faults in our experiments ourselves, so none of them were organic. Intermittent faults are out of scope. And the diagnosis stops at the service. It’ll tell you payments is the problem, but it won’t tell you which line of which config file.
That last limit is what pushed my research somewhere new. If so many of these incidents start with a bad configuration change, then stopping the change is cheaper than diagnosing it afterwards. I wrote about that next step in The merge conflicts Git can’t see.
What frugality is for
The Isha Upanishad is one of the shortest of the Upanishads, and it opens with a line I didn’t appreciate until I was an adult. In rough English: everything here is held by the divine, so enjoy it by letting go, and do not covet what belongs to anyone. These days I read that as a rule about attention more than a rule about money, because it’s hard to enjoy a thing while you can’t stop grasping at it.
I think about this research the same way. The twin is partial, the test plan runs the likely checks first, and the small model only does the one job it’s good at. Each of those came from deciding what matters before spending anything, which is why I don’t count them as compromises or as making do with less. Growing up, that decision was about money. With production on fire it’s about time and attention, and you have even less of those.