Docs›Architecture›CRDT Sync Protocol
Architecture

CRDT Sync Protocol

In larger venues, you might deploy multiple Q-OS edge nodes (e.g., one at the entrance, one at the bar). These nodes must synchronize state without relying on a cloud backend.

#mDNS Peer Discovery

When a Q-OS node boots up, it broadcasts its presence over the local network using mDNS (Multicast DNS). Other nodes automatically discover it and establish a secure, peer-to-peer TCP connection. No manual IP configuration is required.

#Last-Write-Wins Merge Strategy

Q-OS employs a Last-Write-Wins (LWW) Conflict-Free Replicated Data Type (CRDT) for state synchronization. Every mutation in Sled is tagged with a highly precise logical timestamp.

When two nodes mutate the same key (e.g., inventory:sku_0912) while partitioned, they will exchange their transaction logs upon reconnection. The mutation with the highest logical timestamp "wins" and becomes the canonical state across the mesh.

⚠️ WARNING

Because of the LWW strategy, you should avoid relying on absolute counter overwrites if multiple nodes might modify the same counter simultaneously offline. Instead, append to lists or use unique keys per node when possible.