How is it possible to synchronize data between multiple devices?

757 Views Asked by At

Let's say you are writing a program that many clients use. One server will only be able to handle the connections to a certain amount. The more connections you need to handle, the more power you need until you get a server farm containing different devices. If you for example run an application where different clients can store data on your servers how is it possible to synchronize data on each device? Which hardware/software solutions exist? Or how is all the data stored?

2

There are 2 best solutions below

2
On

I can suggest an idea for a manual program creation , using file system only , you can exchange files between clients and server , but the server program will , in a period of time ( for example every 5 minutes ) broadcast the list of all his files to all connected clients and the exchanges will have to wait then ( if we are talking about a big volume of files) if its for small files then a 30 sec or 1 minute can be enough

0
On

There are many forms to do that...

I think you will need to have a single source of truth, let's say (the server on this case).

Then you can have a incremental number version (id) that contains the latest changes.

So each device can poll that number version only in order to know if is up to date.

If not, the device can ask the server the changes from the version that device has.

Each time a device makes a change, that change is stored on the server, and the version is incremented.

That can be one basic implementation. If you need real time updates, you can add to that implementation some publish-suscribe channel using Sockets... or some service like channels from pusher.com

So, every time a device made a change on the server, you can send a notificaiton on the channel with some information (the change) or the new ID of versión and all the devices can update the information via the change (if is only one) or ask the server all the changes if there are many (like the device was disconnected from internet for a while).