mardi 26 mai 2015

Synchronize multiple SQLite Databases with same schema

I have a distributed system, and for data availability I have a sqlite database on every node. This database file should be the same on every node as soon as possible.

lets say I have 3 nodes. Where in the worst case, nobody can connect to each other.

And all three of them changes a value in the database. How can I Sync that?

I only have one table which is important...this table does not get new records nor it will lose records....so there will be only update commands. I will save a timestamp to every entry, so I can determine which is the latest one. (Sure this does not guarantee that the latest value will be the right one, but I need a criteria to choose one automatically)

But what is the best way to sync these databases when the nodes can talk to each other again? I thought of that everybody sends its data via a Socket(which is already available). But isn't that a lack of time when there are a lot of data in the database?

I thought of something like...If all nodes are on and the databases are the same(hash value) I could save a timestamp(T1). So I know that I don't need to send a entry where the update timestamp(T2) is older than T1.

Am I on the right trail, or could you suggest something more sufficent/easier?

Aucun commentaire:

Enregistrer un commentaire