1

What is a low-latency, low-bandwidth algorithm for synchronizing, say, a text file between a client and a server?

Is there a design where the client send a delta of it's current state and it's last ACK'd state from the server? I am thinking Quake3 networking..

EDIT 1:

More specifically, how would a diff/delta algorithm behave in a client/server environment.

e.g. Is it more expensive to calculate a diff on the client side, send to server, server interprets and updates its store, sends ACK to client? Or is it cheaper to have a replication model where client sends its full state and server stores it..?

EDIT 2:

100 KB text file. Something small, not too large.

3 Answers 3

2

You mean like a diff?

Store the server-side's version of the file in the client. Whenever you need to synchronize, run a diff (you can either write your own or use a library). Then send the difference over to the server and have the server patch it's local version.

Sign up to request clarification or add additional context in comments.

1 Comment

I guess a diff/delta algorithm is part of it. I updated the original question to elaborate on what I'm trying to ask
1

If a client also edits text, and has an undo/redo feature then undo stack can be used for delta. For large texts and small changes using undo stack should be more efficient than running a diff.

Comments

1

For text you can use delta algorithm, take a look, for example, on how rsync works.

Google uses a different approach to update chrome, you can "google" it to see.

Edit: If it was a server generating one change and replicating in lots of clients, it should be done in server. From the question's changes, I understood that a client (or many clients) will produce the changes and want them to be replicated on server.

Well... I'd take in account 4 things:

  • network performance
  • number of clients
  • number of changes expected
  • performance of the server and of the client

Too many clients sending and doing that on server: it's almost a DoS I'd only do that on server if there were few clients, high server performance and low client performance. Otherwise, I'd only do that on clients.

1 Comment

Is that efficient in a client/server environment?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.