benbjohnson / litestream

Streaming replication for SQLite.
https://litestream.io
Apache License 2.0
10.69k stars 246 forks source link

Client libraries for replication (iOS, etc) #54

Open wtatum opened 3 years ago

wtatum commented 3 years ago

Hi,

Thanks for releasing such an interesting and exciting project. I'm curious if you have any input on whether this project is suitable for a single-writer, multi-reader project for replicated data to mobile devices for offline use. I know the question has been asked before about using this for replication, but mostly as relates to clustering or data at edge use cases.

I've done this in the past at the API layer but found there to be performance and reliability challenges. Wondering if simply feeding the device as a read replica would be simpler and easier to deliver.

benbjohnson commented 3 years ago

@wtatum Yes, I think that'd be a good feature. Once the read replica (https://github.com/benbjohnson/litestream/issues/8) feature is done, I don't think it'd be difficult to write a Swift library to act as a client to the HTTP replication.

Note: I'm updating the title to reflect this as a feature rather than a question.

wtatum commented 3 years ago

I see. Very cool. Presumably since the replication client only needs a subset of the capabilities (basically, a client SDK to consume the WAL over HTTP and the ability to write to a live DB) the components involved on client-side are simplified relative to the footprint of the full Golang module?

benbjohnson commented 3 years ago

Yes, the client side operations are pretty minimal. It essentially streams down snapshots & WAL frame blobs over HTTP and then uses SQLite to apply the WAL and invalidate the shared memory file (-shm).

gedw99 commented 3 years ago

Would you not need Schema changes to also be replicated via the stream ?

benbjohnson commented 3 years ago

Schema changes would be replicated automatically since they're just stored in the b-tree in the sqlite_master table.

gedw99 commented 3 years ago

@benbjohnson ok thanks. good to know