CRDTs
Data structures that merge concurrent edits automatically — how offline-first health apps sync without a referee.
In one line
A CRDT (Conflict-free Replicated Data Type) is a data structure designed so replicas edited independently — offline, concurrently — always merge to the same state, by mathematics rather than by a central server deciding winners.
The problem it solves
When two people edit the same data while disconnected — a nurse and a doctor updating a care plan during a connectivity gap — what happens when they reconnect? The crude answer is "last write wins," which silently throws away one person's work. CRDTs replace that with a structure where both edits survive and merge predictably, no central referee required.
How it works
The core trick: operations are designed to be commutative — apply them in any order, on any replica, and you arrive at the same final state. That mathematical property is what guarantees convergence without coordination.
- Many data types have CRDT formulations — counters, sets, maps, and rich-text sequences.
- Libraries package them for application use — Automerge and Yjs are the well-known ones.
- The cost is metadata — tombstones (to remember deletions) and per-item clocks add overhead.
The clinical caveat
A crucial distinction: merging without conflict is not the same as merging with clinical sense. The math can auto-merge two medication edits into a coherent data structure that is still clinically wrong. So a deliberate human review step can be the right design even when the CRDT could merge silently — automatic convergence is a sync guarantee, not a safety guarantee.
Where it shows up in digital health
- Community-health-worker apps that work offline for days — the offline-first pattern in LMIC and rural deployments (directly relevant to India-scale reach).
- Collaborative care-plan editing.
- Sync layers of PWAs — including the offline reading this platform plans.
CRDTs are why "last write wins" is no longer the only answer to two clinicians editing the same note in a connectivity gap.
Common pitfalls
- Assuming auto-merge = correct — converged data can still be clinically nonsensical; add review where safety demands.
- Metadata growth — tombstones and clocks accumulate; understand the storage cost.
- Reaching for CRDTs when you don't need them — if you have reliable connectivity and a server can arbitrate, simpler models may suffice.
Key takeaways
- A CRDT merges concurrent, offline edits to one consistent state — by commutative math, no referee.
- Automerge/Yjs implement them; the cost is metadata overhead.
- Convergence is a sync guarantee, not a clinical-correctness guarantee — review where it matters.
- The backbone of offline-first health apps — vital for low-connectivity, India-scale reach.
अपना स्मरण जाँचें
2 में से 0 याददोबारा पढ़ने से बेहतर है सक्रिय स्मरण — पहले उत्तर सोचें, फिर देखें।
What problem do CRDTs solve?
The clinical caveat for CRDTs?