Client / Server data exchange

I have a client using ‘y-indexeddb’ and server using a database which updates on client changes etc.

What I’m trying to understand is what happens when a client connects to the server. Does the server send it’s entire database to the client or only yDoc's that have changed and/or don’t exist in the clients indexeddb store.

Conversely does the client send it’s entire indexed db to the server when it starts?

If the databases are sent in one of both directions in their entirety this could be expensive in time and data use for large databases.

I have only just started with yjs but have read lots of docs and searched here on the forum and haven’t found an answer to these questions.

Welcome to the discussion board @clibu,

This really depends on the provider implementation (e.g. y-websocket or y-webrtc). But all my providers sync document states by syncing only the differences. Basically, the client and the server send a small “state-vector” to the other side that describes the local state. The other side calculates a diff sends it back. This mechanism is documented here: https://docs.yjs.dev/api/document-updates#example-sync-two-clients-by-computing-the-differences

When the document content is already available in y-indexeddb, the y-websocket provider only needs to sync the differences since the last session.

1 Like

@dmonad Thanks for the detailed reply. It is very good to hear this process is efficient in time and space.

I am on a steep yjs learning curve and making slow but steady progress.

It would be great to see the Docs at https://docs.yjs.dev/ having more love. I’m sure the time you spent completing the docs would pay off in less of your time spent here and on gitter and be of great help with folks learning and using your great work.

Yjs is an open-source project and it depends on people to contribute in the long term. I can’t be the only one doing all of this. So if you feel the documentation is lacking (which is true), I’d be happy to receive your contribution :slight_smile:

1 Like

I agree 110%. I’ve just forked the docs and also sponsored you. I don’t understand why you don’t have more sponsors and even more so, why no large companies are backing your great and important work.

I’ve come across some mistakes in the docs and will start there. If I can build up more knowledge I’ll contribute further. I am thinking about writing an article on yjs, as there seems to be little around.

Hey @clibu,

your financial contribution and - even more so - your work on the docs are much appreciated! Really :heart: