What are the steps to add replication to a non-replicated database?

0
1
Asked By CleverPineapple42 On

I'm curious about how to add a replication layer to a database that doesn't already have one, like SQLite. For instance, there are SQLite-compatible databases that have managed to incorporate replication using methods like RAFT or CRDTs. If I were to embark on such a project, what would be the main steps? Is it just a matter of watching for changes, packaging those changes, and sending them over a network? I'd love to get some insights on how to tackle this systematically!

3 Answers

Answered By ThoughtfulPenguin77 On

A heads up, multi-master replication can be really complex, especially if one instance succeeds and another fails. You might have to rollback changes on the ones that succeeded to keep things consistent. This is where powerful systems like Cassandra with QUORUM and LOCAL_QUORUM checks show their value, although they usually rely on eventual consistency.

Answered By CreativeGiraffe99 On

One common approach is to use log shipping. Basically, when you make a write to the database, the change goes into a write-ahead log (WAL). You can then send these changes to another server. When you're ready to commit the transaction, you commit on both databases, but you should implement a 2-phase commit for reliability. Just keep in mind that actually making this work isn’t straightforward, especially for embedded databases like SQLite which might not derive much benefit from added complexity. Other databases like MySQL and Postgres already have built-in replication features.

Answered By DedicatedFalcon23 On

Interesting project you're working on! Some databases may not have a WAL like SQLite does, which complicates things a bit. You'll need to figure out how to handle changes from users seamlessly, especially in a local-first distributed setup. I think the idea of having all users interconnected on the same graph network is ambitious and could be quite rewarding!

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.