Offline Synchronisation for Intermittently Connected Applications
A conflict resolution strategy for mobile clients that spend long periods offline, evaluated against three months of field traces.
- Authors
- Sidney Okine2SVII, co-founderSamuel Okine2SVII, co-founder
- Published
- Updated
- Reading time
- 3 min
Research summary
- Problem
- Applications used on intermittent mobile networks accumulate large divergent local histories. Last-write-wins discards work that the user believes was saved, and full operational transformation is heavier than most product teams can justify maintaining.
- Objective
- Establish whether a bounded, per-field merge strategy can resolve the majority of real divergence without server-side operation replay, and quantify what it fails to resolve.
- Methodology
- We instrumented a production field-data application across 41 devices for 94 days, recording every local mutation and its eventual server reconciliation. Divergence events were replayed offline against three strategies: last-write-wins, per-field last-write-wins with vector clocks, and a state-based CRDT baseline.
- Findings
- Per-field resolution with vector clocks resolved 96.2% of observed divergence events without user intervention, against 71.4% for whole-record last-write-wins.
- The residual 3.8% clustered almost entirely in list reordering, which per-field resolution cannot express.
- Metadata cost was 180 bytes per record at the observed replica count, roughly 11% of mean record size.
- Limitations
- A single application domain with 41 devices. Divergence patterns are workload-specific and these results should not be assumed to transfer.
- Median offline period was 4.2 hours. Behaviour beyond roughly 72 hours offline is not characterised.
- The CRDT baseline was implemented for this evaluation and is not a tuned production implementation, so its overhead figures are an upper bound.
Applications that assume connectivity behave badly without it. On networks where a session may drop for hours, the client accumulates a local history that the server has never seen, and the reconciliation strategy chosen at design time determines whether that work survives.
The prevailing default is last-write-wins on the whole record. It is simple to implement and it silently destroys data: two users editing unrelated fields of the same record will see one edit vanish. The alternative usually proposed is a CRDT [shapiro-2011], which is correct but carries a maintenance and storage cost that small teams frequently underestimate.
Method
We instrumented an existing field-data collection application already deployed on intermittent networks. Every local mutation was recorded with a vector clock [fidge-1988] and a monotonic device counter, then shipped alongside the mutation when the device next reconnected.
type FieldVersion<T> = {
value: T;
clock: VectorClock;
deviceId: string;
};
function mergeField<T>(local: FieldVersion<T>, remote: FieldVersion<T>): FieldVersion<T> {
const ordering = compare(local.clock, remote.clock);
if (ordering === "descends") return local;
if (ordering === "ascends") return remote;
// Concurrent. Neither clock dominates, so there is no causal answer and any
// choice here is arbitrary. Ordering by device id at least makes it the same
// arbitrary choice on every replica, which is what convergence requires.
return local.deviceId > remote.deviceId ? local : remote;
}Results
| Strategy | Resolved | Metadata / record | Escalated to user |
|---|---|---|---|
| Whole-record last-write-wins | 71.4% | 24 B | 0% |
| Per-field + vector clocks | 96.2% | 180 B | 3.8% |
| State-based CRDT baseline | 99.1% | 1.4 kB | 0.9% |
The CRDT baseline resolves more, as expected. The question is whether the remaining 2.9 percentage points justify roughly eight times the metadata and a substantially larger implementation surface. For the workload measured here we judged that they did not, and the residual list-reordering cases were escalated to an explicit user prompt instead.
Reproducing this
The anonymised trace set and the replay harness are published alongside this record. Device identifiers are salted per-device and the field payloads are omitted; the harness replays divergence structure only.
References
- [shapiro-2011]Shapiro, M., Preguiça, N., Baquero, C., Zawirski, M. (2011). Conflict-free Replicated Data Types. Stabilization, Safety, and Security of Distributed Systems, pp. 386–400.
- [fidge-1988]Fidge, C. J. (1988). Timestamps in message-passing systems that preserve the partial ordering. Proceedings of the 11th Australian Computer Science Conference, pp. 56–66.
Related
Technical ArticleBeta
Drift — a synchronisation engine for unreliable connectivity
A TypeScript library implementing per-field conflict resolution with vector clocks, extracted from the offline synchronisation research.