服务调研关于联系
← Back to Research
2026-07-24OpenWrt·

The Machine That Never SleepsDissecting the Monitoring and Redundancy of a Production-Grade 24/7 Automation System

The Machine That Never Sleeps: Dissecting the Monitoring and Redundancy of a Production-Grade 24/7 Automation System


I. Real Engineering Lives on the Failure Path

A script that only runs the "happy path" and a production-grade system may look nearly identical at the code level. The difference hides where you cannot see it:

There is one rule of thumb worth committing to memory first: in a truly 24/7 system, business logic often accounts for only about thirty percent of the code; the remaining seventy percent is "monitoring whether it's actually doing its job" and "what to do when some link in the chain fails." The rest of this essay dissects that seventy percent.

The sample system is made of four parts: an enterprise-grade router (the network gateway), a cloud VPS (the frontline executor), a local Mac control hub (perception and decision-making), plus an on-chain asset monitoring and automated-response system that runs on the VPS and must react to external events within seconds. Compact in size, complete in its organs — every pitfall a production-grade system ought to hit, this one hit every last one.


II. Three Devices, Each to Its Own Duty

The first layer of reliability isn't in the code — it's in the architecture: no single machine is simultaneously the brain and the limbs.

Three devices, each to its own duty: brain, gateway, frontline

DeviceRoleWhat it runsWhy it lives here
Enterprise routerNetwork gateway · link lifelineLink health, proxying, DHCP, high-throughput forwardingThe mandatory gateway for all intranet traffic; it decides whether the other two can even talk to each other
Local Mac control hubPerception · decision · human interfaceGlobal scanning, scheduled patrols, alert aggregation and pushWhatever a human needs to see, decide, or aggregate lives here — it's allowed to be powered off
Cloud VPSFrontline · 24/7 business executionResident services, on-chain monitoring, automated execution, watchdogAnything that "must never stop for a moment" can only live in the ever-awake cloud

One line captures the crux: the control hub is allowed to sleep; the frontline executor is not. So duties split this way — "must be 24/7" goes on the VPS, "needs a human in the loop" goes local, "the network lifeline" is the router. The separation is itself a form of redundancy: when the local Mac's lid is shut and it's asleep, the business on the VPS keeps running unaffected — something a single-machine "brain-and-limbs-in-one" design simply cannot do.


III. Concentric Circles: Who Is Watching Whom

This is the single most important diagram in the essay.

The most common beginner's misconception is to think "I added monitoring" equals "I installed an alarm." The truth is: monitoring is layered, and —

each layer can only see the class of failures its inner layer is blind to.

Picture it as an onion, wrapped from the innermost business logic outward, layer by layer, to the outermost "human attention":

Concentric monitoring: each layer catches the failures its inner layer cannot see

LayerWhat it watchesMechanismWhat it can't see (handed to the next layer out)
① Business logicProbe → judge → executeThe script's main loopDoesn't know whether it itself has "died"
② Process livenessWhether the process has exitedsystemd Restart=alwaysA process that's "alive but frozen and not working"
③ Process healthWhether the live process is actually workingWatchdog WATCHDOG=1 / restart after 7 minThe whole machine losing power, network, or crashing
④ Node livenessWhether the entire remote machine is onlineControl hub's scheduled SSH probeOnce found — who tells the human
⑤ Perception aggregationRolling up all anomaliesSnapshot + hourly pushStill needs to actually reach a person
⑥ Human attentionWhether the human ultimately knowsA push landing on a phone— the end of the chain

Reading down layer by layer, you find every layer has a hole it can't fill itself, which is precisely the reason the next layer exists:

The value of this chain lies precisely in dividing the labor of watching different ways to die. No single layer can cover all failures on its own; stacked together, they weave a net with no obvious holes.


IV. The Economics of Frequency: The Cost of a Miss Sets the Tempo

If you're going to monitor, how often should you look? Once per second, uniformly? Too expensive, and unnecessary. The correct answer is a plain piece of economics:

Patrol frequency is proportional to "the cost of missing one detection."

The economics of frequency: patrol frequency is proportional to the cost of a miss

FrequencyWhat's monitoredCost of one miss
3 secondsCore state probe (external event flip)Total loss of assets — every second has a price
60 secondsResource movement (balance / resource flow)Important but not fatal; minute-level is enough
7 minutesProcess-health watchdogA zombie goes unnoticed; but "freezing" itself is rare, no need to go tighter
1 hourPerception-aggregation pushDiscovering a failure an hour late is usually still salvageable
24 hoursLiveness heartbeatPure backstop, only to prove "I'm still here"

A counterintuitive but crucial corollary: not everything deserves high-frequency monitoring. Polling "whether the git repo has committed on time" every single second only burns resources and drowns the alerts that actually matter under noise.

Frequency mismatch — the urgent gone slow, the trivial gone fast — is the most common ailment of a beginner's monitoring system. Poll a core event at hourly cadence and you'll miss the life-saving window; refresh an irrelevant status at second-level and you'll train yourself into "cried wolf" numbness. Align each item's monitoring frequency with "how much a single miss costs," and this system's patrol tempo layers itself naturally.


V. Six Forms of Redundancy: A Single Point of Failure Need Not Be Fatal

Monitoring is responsible for finding problems; redundancy is responsible for not collapsing when a problem occurs. The redundancy in this system sorts cleanly into six kinds — the key being that each kind plugs a different single point.

Six forms of redundancy: each plugs a different single point of failure

FormPracticeThe single point it pulls out
① Channel redundancyAlerts go over two Telegram channels at once (a group + a direct message)A single channel going dark
② Data-source redundancyExternal state is queried from two independent nodes; actions are dispatched to several nodes at onceA single node failing or "lying"
③ Judgment redundancyNever trust intermediate signals; go by the authoritative result, and rule "unknown" on any ambiguityA false report of success
④ Self-healing redundancyAuto-restart on crash; on a freeze, the watchdog kicks it into a restartProcess zombification
⑤ Liveness redundancyLayered heartbeats + cross-device probing; there's always a layer that can prove the whole is still aliveTotal loss of contact
⑥ Temporal redundancyFailure doesn't mean giving up; if the condition still holds, try again next roundAn occasional single-shot failure

Two of these forms deserve unpacking, because they're where beginners most easily go wrong:

③ Judgment redundancy — do not trust intermediate signals. An action having "already been dispatched" does not equal "succeeded." The right approach is to confirm by querying back the authoritative final result, not by looking at "whether the dispatch was accepted." Likewise, when a state query returns something ambiguous (half a payload, an error code, an empty response), you must never guess a direction on its behalf — treat it as "unknown" without exception; rather re-query next round than fire an irreversible action on a guess. This one was bought with a real incident: "reporting a failed operation as a success."

⑥ Temporal redundancy — a failure is merely "this round didn't land." It leads directly into the next section, and it's the most expensive lesson in the whole system.

To evaluate any piece of redundancy, you really only need to ask one thing: which single point does it pull out? If you can answer, it earns its place; if you can't, it's most likely over-engineering that only makes you "feel safer."


VI. Edge vs. Level: A One-Word Difference Between Life and Death

This is the most expensive lesson in the entire system, and it deserves its own section.

The early version used edge-triggering: it acted only "in the instant the state flips." Logically natural — the moment the condition is met, charge.

The problem is: what if that one shot doesn't land? A network jitter, insufficient resources, a node returning half a payload… so long as that one attempt fails, and "the instant of the flip" has already passed and will never come again, the system is permanently disarmed. Even if the condition truly holds forever afterward and execution truly remains possible, it won't move — worse, it thinks everything is fine.

Rebuilt, it switched to level-triggering: it doesn't watch "the instant of the flip," only "whether the condition currently holds." As long as "executable ∧ not yet succeeded," it retries every round; if one fails, the next picks it right up, until it confirms the job is truly done and only then stops.

Edge vs. level: is one failure a total loss, or just wait for next round

The distinction sounds abstract, but its cost is extremely concrete:

Edge-triggered (v1)Level-triggered (v2)
Consequence of one failureTotal loss, and silentJust "this round didn't land," auto-retries next round
Self-healingNone — miss the instant and it's permanently deadYes — keeps trying as long as the condition holds
Failure visibilityPretends nothing happened — the most dangerousLeaves a trace every round, observable

The accompanying watchdog is, in fact, another application of the same philosophy. The watchdog doesn't go "detect some specific failure" — it inverts the problem, demanding that the process continuously prove it is working: shout "I'm still alive" after each round of work, and get restarted if it can't shout.

Rather than enumerate every possible way to die, require the program to keep producing "proof of life." You can never list in full how a system might die; but you can require it to "restart if it can't prove it's working." This is the flip from "exhaustively enumerating failures" to "demanding proof of life," and it's where the watchdog's real power lies.


VII. The Philosophy of Alerting: Better to Wake You Than to Go Blind

The far end of monitoring and redundancy is a single message landing on a human's phone. This last link has its own craft, and a few battle-tested principles:

PrincipleExplanation
Severity tiersOnly the fatal (assets / a whole machine) gets Critical, worth waking you at midnight; the routine (a repo long uncommitted) drops to Warning, aggregate is enough
Dedup + cooldownThe same "low on fuel" fires at most once per hour; otherwise it floods the screen, which equals not alerting at all
Silence the known-harmlessA laptop taken out the door, an intranet probe failing to reach the router — this is the normal "leave home, go offline"; it shouldn't alert, or you cry wolf daily and go numb before the real wolf comes
Alerts should self-attestAfter a process restarts, it proactively sends "I'm back up," so you know it just went through a self-heal rather than restarting silently and pretending nothing happened

Of these, "silence the known-harmless" tests your sense of proportion the most. In this system's perception engine, the "remote node offline" alert deliberately skips that enterprise router — because the most common reason it can't be probed is that a local device was carried out the door (no longer on the same intranet), which is a known-normal state; what truly warrants waking a person is that VPS, which is supposed to be online 24/7, going dark. Sift the known-normal fluctuations out of your alerts, and every one that remains becomes worth looking up for. The enemy of an alerting system was never just "false negatives" — "cried wolf" over-alerting will disable it just as surely.


VIII. Closing: Reliability Is an Onion, Peeled One Layer at a Time

Looking back, there's no single "silver bullet" anywhere in this system. It's reliable because a string of plain things are stacked together:

Duties split across three devices → six monitoring layers each watching a different way to die → six forms of redundancy each plugging a different single point → frequency allocated by cost → triggering by level, not edge → alerts tiered, deduped, then handed to a human.

Each layer, viewed alone, is utterly unremarkable; stacked together, they become "you dare not look at it for three months."

If you take away only one line from this essay, I hope it's this:

Business logic decides whether it can work; monitoring and redundancy decide whether it can work unattended for the long haul. The latter is the whole meaning of the words "production-grade."

Share
← Back to Research

Related · TryWay Labs

長為試之印(盖印版·自然崩口)
AI 实战2026-07-13
Vectors, Retrieval, and RAG · How to Build a Search System That "Speaks Only From the Source