Intermittent connectivity and local fallback
Define useful offline decisions, versioned state and bounded synchronization demand while handling stale information and ambiguous remote outcomes.
On this page
The question for today
What you’ll understand
- Calculate outage storage and recovery drain time under explicit flow assumptions.
- Specify a validated local fallback with freshness and version semantics.
- Handle ambiguous remote outcomes without assuming retries are exactly-once.
A device can lose connectivity without losing its ability to sense or compute. Whether it should keep making decisions depends on the task, the freshness of local data, and the quality of its fallback. Design this behavior explicitly rather than waiting for a network timeout to choose it accidentally. Offline capability includes durable state, version compatibility, bounded queues, and a reconciliation policy when the network returns.
Make offline behavior a product contract
Name which functions remain available locally and which require a remote service. A smaller on-device model, cached rules, or an explicit unavailable response can each be appropriate when its consequences are understood. Validate the fallback on the workload it will receive during outages, which may differ from ordinary traffic. Record the local model and preprocessing version with each result so a later server response can be reconciled without pretending the two decisions came from the same pipeline.
Cached context also has a freshness contract. Distinguish the age of data from the time since the last successful network request; a freshly downloaded response can contain old source data. Use explicit source versions and trusted time assumptions where needed. A device’s wall clock can jump, while a monotonic elapsed timer usually does not survive every reboot with the same origin. Specify how restart, clock uncertainty and expiration affect continued operation rather than silently extending validity whenever the device is offline.
Queue synchronization without claiming exactly-once effects
Persist queued records before acknowledging a durable local submission, and define what happens when storage fills. Coalescing the latest state can be suitable for replaceable telemetry but destructive for an audit event or user action. On reconnect, bound retry traffic and reserve capacity for new arrivals. The server and client need compatible record schemas, artifact identifiers and deduplication rules. A locally successful prediction does not imply that a related remote transaction was committed or that its delayed response is still useful.
A request can reach the server and commit while its response is lost. Blind retry can then repeat a non-idempotent effect. Use a task-specific idempotency key and server-side durable outcome handling when the operation requires it; HTTP method semantics alone do not give arbitrary application actions exactly-once execution. Set an expiration or reconciliation rule for late results, and test restarts after sending but before recording acknowledgment. Backoff reduces retry pressure but does not resolve uncertainty about an earlier commit.
Test disconnection as a normal operating condition
Exercise prolonged offline operation, flapping connections, captive portals, expired credentials, full storage, process death and clock changes. Verify the local decision policy, durable queue and eventual reconciliation together. Android’s offline-first guidance illustrates separating local and network data responsibilities, but it is architecture guidance rather than a guarantee that every model result or write synchronizes automatically. Measure recovery under a fleet reconnect burst so a server-side bottleneck does not turn a local outage into a much longer incident.
The queue instrument demonstrates net draining only. Reset, set arrival lambda to 2 and service mu to 4, predict backlog two after two Steps and zero at two seconds, then take two Steps. Continue two more Steps to see the drain. Compare a fresh Reset with both lambda at 4 and mu at 4 before two Steps: backlog stays four. It starts with four cases and models constant rates, not persistent storage, network failures, deduplication or record acknowledgment.
Work it through
Budget a five-minute outage and recovery
An initially empty device queue receives two fixed-size 512-byte records per second during a 300-second outage. Capacity is 1,000 records. After reconnect, successful upload capacity is five records per second while new arrivals continue at two per second. Ignore metadata, retries and bandwidth variation.
The outage creates 2 × 300 = 600 records, below the 1,000-record capacity. Their data occupies 600 × 512 = 307,200 bytes.
The full data-only capacity is 1,000 × 512 = 512,000 bytes, leaving space for 400 more records under the stated fixed-size assumption.
Recovery removes backlog at net rate 5 − 2 = 3 records/s, so 600/3 = 200 seconds are needed to empty it. This assumes every counted upload completes successfully and excludes retries or a fleet-wide server bottleneck.
Local availability requires both enough outage storage and enough successful recovery capacity beyond continuing arrivals.
The living notebook
Explore the model
Interactive lab · queue
Recovery capacity must exceed new demand
Reset, set λ = 2 and μ = 4, predict Q(1) = 2 and drain at t = 2 seconds, then take four Steps to inspect the full drain. Compare a fresh Reset with both λ = 4 and μ = 4 before two Steps: Q(1) = 4. Initial backlog is 4 and Step adds 0.5 seconds. This is constant-rate fluid accounting, not an offline synchronization protocol.
- Fluid backlog
- 4
- Net rate · λ − μ
- −1 /s
- M/M/1 mean residence
- 1 s
Fluid backlog starts at 4 and follows max(0, 4 + (λ − μ)t). The separate M/M/1 residence-time formula assumes Poisson arrivals, exponential service and λ < μ. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.
Look forA reconnect event alone does not imply that a backlog can drain.
Pause & reason
Check your understanding
Your turn
Try it yourself
An empty queue receives three 200-byte records per second for a 120-second outage. After reconnect, successful service is six records per second while arrivals remain three. Compute queued data and drain time; explain what changes if service is only three.
Take a moment to make a prediction or work it out on paper. Open a hint when you need one.
Give me a hint
First count records accumulated during the outage, then subtract continuing arrivals from successful recovery capacity.
Compare with the solution
The outage accumulates 3 × 120 = 360 records, occupying 72,000 data bytes. Net recovery is 6 − 3 = 3 records/s, so drain time is 360/3 = 120 seconds under the constant-rate assumptions. At service three, new arrivals exactly consume capacity and positive backlog never drains unless the policy changes demand, service or retained work. A finite storage budget still needs an explicit overflow rule.
Keep the idea
Take it with you
- Define useful offline behavior and the freshness of its inputs.
- Bound durable queue growth and validate net recovery capacity.
- Treat lost responses as ambiguous outcomes governed by an explicit reconciliation protocol.
Read further
Original sources and deeper explanations to follow at your own pace.
Optional progress, saved in this browser when available. Revisit any lesson at any time.
Lesson not marked complete.