@benbjohnson
Ben Johnson
2 years
It's still rough but I got live read replication working for Litestream. This demo app on @flydotio has a SQLite DB in Chicago that's replicated out to 15 other regions around the world in real-time. Click the button and watch the replication propagate!
8
35
255

Replies

@benbjohnson
Ben Johnson
2 years
It's a tiny DB but the same principle works for larger databases. Litestream watches the WAL on the primary and extracts the new writes like it normally does. Replicas connect over HTTP and wait for those WAL changes to be pushed to them.
1
1
17
@benbjohnson
Ben Johnson
2 years
The replicas then write to the local WAL and invalidate the -shm file which causes SQLite to rebuild the shared memory index. Finally, Litestream on the replica checkpoints the WAL into the DB.
1
0
11
@benbjohnson
Ben Johnson
2 years
The other fun thing that happens is that new snapshots can be sent down and they are rewritten as a WAL so that the DB can be overwritten in a transactional way.
0
0
9
@deliberatecoder
Michael Lynch
2 years
@benbjohnson @flydotio I just heard about server-sent events this week for the first time, and this is the first code I've seen that uses that feature. Way easier to use than I expected!
1
0
5
@benbjohnson
Ben Johnson
2 years
@deliberatecoder @flydotio They're awesome. I almost always try to use them instead of WebSockets. Really simple and easy to debug.
2
0
16
@dholth
Daniel Holth
2 years
@benbjohnson @flydotio Oh, not in the current documentation
1
0
0
@benbjohnson
Ben Johnson
2 years
@dholth @flydotio What do you mean?
1
0
0
@joonas_fi
Joonas Loppi
2 years
@benbjohnson @flydotio Very cool to see in realtime! Good job 👍 BTW lhr seems to be left behind, maybe a bug? 🙂
1
0
0
@benbjohnson
Ben Johnson
2 years
@joonas_fi @flydotio Thanks! Yeah, I’m sure it’s a bug. It’s definitely still a rough first pass so it needs work. I’m going to be cleaning it up and testing it over the next month and a half and hopefully release at the end of March.
0
0
1
@awkroot
omar
2 years
@benbjohnson @flydotio link doesn't work anymore
0
0
0
@benbjohnson
Ben Johnson
2 years
@enricoschaaf @flydotio Yep! You can find the demo app here:
0
0
10
@JohanBrandhorst
Johan Brandhorst-Satzkorn
2 years
0
0
1