I have a collaborative server to apply all the updates from the clients, and I want to discard some intermediate updates for the same kind of update message but only get the final result like throttling applyUpdate on server-side, but I failed. Is it required for a ydoc to apply all the updates sent by the clients and cannot discard some intermediate changes?
e.g. In a case of spinning a rect, Client A: update 1 (0 degree) → update 2 (30 degree) → update 3 (60 degree) → update 4 (90 degree), and is it possible for the server to only applyUpdate for update 1 and update 4?
Intermediary updates can’t be discarded, I think because they form a linked list of updates that depend on each other internally. However, you can queue multiple updates and use
Y.mergeUpdates in a throttled function to generate a single update and apply it to the Doc.
Thanks for your advise, but I’ve already tried Y.mergeUpdates and it doesn’t solve my performance problem on the server-side, because the server needs to apply too many updated from the clients, and merging these updates do not really help.
Yeah, performance comes up quickly with a lot of updates.
I recommend throttling updates on the client-side as much as possible. There’s no point spending the bandwidth just to discard updates on the server.
If it’s ephemeral, real-time information that you’re sharing, you could switch to Awareness which is lighter weight, and just store major checkpoints permanently.
Horizontal scaling can help with server load, but that won’t help if you’re experiencing performance issues with a single Doc shared by many users.