orbitinghail / sqlsync

SQLSync is a collaborative offline-first wrapper around SQLite. It is designed to synchronize web application state between users, devices, and the edge.
https://sqlsync.dev
Apache License 2.0
2.39k stars 34 forks source link

content addressed replication #49

Open carlsverre opened 10 months ago

carlsverre commented 10 months ago

Supercedes #45

In this replication variant, pages are replicated based on their content hash. Thus the current state of the file can be computed from the content store (provides access to pages by their content hash) and the current snapshot (list of content hashes).

Hash algorithms

snapshot size

assuming an object size of 4k and a hash output size of 32 bytes, a 1GB database snapshot will consume 8MB

notes on efficient replication

carlsverre commented 10 months ago

Since SQLite changes it's header on every write to the database file, we should consider extracting the header (or simply the first page) out into the snapshot (or just sending the first page along with snapshot updates).