The week before launch, I did something pretty dumb: I changed the model key in the production environment to a string of gibberish, then refreshed the page.
The page spun for about thirty seconds, the frontend axios timed out, and what the user saw was the browser’s default error message. The backend log had only one line, ReadTimeout, with no request ID, no record of degradation, and no way to know how many people happened to hit it during that half minute.
That was the moment I admitted that the so-called “degradation plan” up to then was really just a few try/except plus a line of return "系统繁忙,请稍后再试". That’s not a plan; that’s hiding the exception.
First, draw the line of “what must not degrade”
At first I was also thinking “what if the model goes down.” Later I realized I was asking too early. The better question is: in this pipeline, what things turn into an incident once they’re degraded?
I broke down a typical Q&A pipeline into four stages: retrieval, generation, post-processing, and writing to the database. For each stage I asked one question: if this step fails, can it be skipped?
Retrieval failure can be skipped, degrading to a pure model answer, but the frontend must clearly label “this response did not cite your documents”; generation failure can switch to a smaller model, or first give a cached approximate answer. The post-processing stage cannot. Citation validation, sensitive-word filtering, format validation—skipping them is handing unchecked content straight to the user. Better to give no answer this time. Permission checks, quota deduction, and audit log writes don’t even warrant discussion; they should never appear as degradation options at all.
The line I drew for myself is: only “generation” can degrade, “validation” cannot. If generation quality is a bit worse, the user can tell, and can still judge for themselves whether to trust it; if validation skips a step, the user can’t tell, and by the time they can, it’s too late.
The criterion here isn’t technical difficulty; it’s whether you can explain it clearly after something goes wrong. Once the line is drawn, degradation stops being a technical problem and becomes a product judgment: which losses can be put out in the open, and which cannot retreat a single step.
Degradation is a matrix, not a chain
The earliest version was a chained fallback: primary model fails, go to the small model; small model fails, go to cache; cache misses, return a fallback message. After two weeks it became clear this was wrong—it masks problems. A retrieval service outage and model rate limiting go down the same chain, look identical in logs and monitoring, and during a postmortem you can only guess.
Later I changed it to tiers by failure type. Each tier must spell out three things: trigger condition, what the user sees, and how to exit.
| Failure | Trigger condition | Degradation action | User-visible |
|---|---|---|---|
| Primary model timeout | 3 consecutive times over 8s | Switch to small model, cut context in half | Top banner: “The answer may be shorter” |
| Rate limited | 429 or QPS over threshold | Enter queue, answer cache-hit questions first | Show queue position |
| Retrieval unavailable | Health check fails consecutively | Pure model answer, citations off | Label “documents not cited” |
| Tool call failure | Same tool errors 2 times consecutively | Disable that tool, degrade to Q&A | Notice “real-time data not queried this time” |
| Full pipeline failure | None of the above apply | Static fallback + handoff-to-human entry | Clear explanation + retry button |
The thresholds in the table have no universal value. 8s was set based on the latency distribution of that pipeline at the time; in another scenario it might be 3s. A timeout threshold wider than the normal P99 is as good as not setting one. What really needs to be locked down isn’t the number, but “who sets this number and how often it gets reviewed.”
In code, drive it with a config table rather than ifs scattered everywhere:
1 | DEGRADE_LEVELS = [ |
Note the trace.tag line. What degradation fears most isn’t degradation itself, but degrading without anyone knowing. I tag every request that goes down a degradation path and pull a separate curve on the metrics dashboard. If that curve stays non-zero for a long time, it means the upstream is simply unstable—it must not be read as “the degradation plan is working well.”
There’s also the number of tiers. Five tiers looks complete, but each additional tier means another set of copy, another test case, another state that can get stuck. For an internal tool called a few dozen times a day, one fallback message plus one alert is enough; building the matrix to five tiers will likely cost more to maintain than the failure itself. Whether it’s worth going this fine depends on how big the loss from failure is, not on how complete the plan looks.
Exit conditions are easier to forget than entry conditions
Degraded states stick. After the retrieval service recovered, traffic still all went to pure model answers, because I stored the degraded state in process memory, and only new requests would re-probe. Later I changed it to a circuit breaker with a half-open state: every so often, let a few requests probe the primary path, and only recover fully once they succeed.
The switch has to actually be flipped once
In the last week before launch, I ran a round of destructive drills, about two hours in total. The actions were crude:
- Change the model key to gibberish, run through the main flow.
- Change the timeout threshold from 8s to 50ms, creating widespread timeouts.
- Use a script to max out concurrency against the upstream, and see whether the queue piles up after 429, and at what point it drags down the web process.
- Stop the retrieval service container outright.
- After each step, restore and observe for ten minutes to confirm nothing is stuck in a degraded state.
The first round exposed more problems than I expected: the queue had no upper limit, and after upstream rate limiting, tasks piled up to over four thousand in memory and eventually OOM’d; the fallback copy said “system busy,” and users had no idea what happened; and there was a small trap—the frontend treated the degradation flag as an error code and popped a red toast, scarier than the original error.
These things can’t be thought up at the design stage; you have to actually flip the switch once. The drill itself doesn’t need to be as formal as chaos engineering, but the recovery steps and observation window are mandatory—otherwise you’re just manufacturing an incident.
The user-facing copy has to be written in advance
I used to treat degradation copy as an operations matter, until I realized it’s part of the design.
The problem with “System busy, please try again later” is that it lumps all degradations into one thing. But what the user really needs to know is three things: was my question understood, can the answer be trusted, and should I retry. Mapped to the interface, roughly:
- Degraded but still gave an answer: a light banner at the top stating exactly what’s weaker (documents not cited / real-time data not queried / answer may be shorter).
- Queued: show position and approximate wait time, allow leaving the page, notify when the result is ready.
- No answer at all: state clearly which step got stuck, provide a retry button and a handoff-to-human entry.
Semi-degradation is more dangerous than outright failure. With outright failure, the user knows to start over; with semi-degradation, they’ll assume the answer is accurate and go use it. This is also why I insist on labeling in the interface rather than degrading silently—silent degradation saves us trouble and shifts the cost to the user.
The toughest item on the launch checklist
The last item on the checklist is fixed: delete the primary model’s key and run through the main flow again with a real account.
If it doesn’t work, don’t ship. This action is more effective than any degradation design document, because it doesn’t care how well the document is written—it only cares what the user will see in the worst case.
The next thing I want to address is cache-layer consistency: when falling back to cache_only, it returns historical answers, and if the user’s data changed in the meantime, the answer is wrong. I haven’t decided whether to add a data version number or simply refuse to answer during fallback. The current default is the latter—a wrong answer costs more than no answer. But whether the refusal rate will be high enough to hurt the experience still depends on canary data.
Comments