Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestions for improvement #2

Open
gaberogan opened this issue Feb 16, 2021 · 1 comment
Open

Suggestions for improvement #2

gaberogan opened this issue Feb 16, 2021 · 1 comment

Comments

@gaberogan
Copy link
Owner

From WinstonFassett:

I think you can save a lot of DynamoDB data loading and lambda cycles per ws message by avoiding calling getOrCreateDoc unless you really need it.
For example with messageAwareness messages, you can just broadcast and return early because they don't mutate the doc.
Even with messageSync messages, you may only really need to load the doc for writeSyncStep1.
That is to say, you might be able to skip loading the doc even for updates, because you are just doing a push and a broadcast
I see that you are calling Y.applyUpdate but it doesn't seem like that is necessary when just pushing an update to dynamo and rebroadcasting the original message
I think with those changes you would only ever have to actually read from DynamoDB and load the document and apply all known updates when clients send writeSyncStep1 after connecting

From dmonad:

Loading Yjs documents is the most expensive operation in y-websocket server. So my approach is to avoid loading the document by computing the differences directly on the binary update messages using the API I proposed here: yjs/yjs#263

It would be great if you could publish your work on https://discuss.yjs.dev/ if you want to make it available (using the "show" tag).

@rlingineni
Copy link

rlingineni commented Aug 16, 2021

@gaberogan - Thanks so much for putting this together! The demo works. Have you done any tweaks to this library? I'm going to take a look at it later today. I'l likely rewrite in Typescript. I'm thinking of combining it with the serverless framework, looking into the mergeUpdate method, and look at the optimizations that are suggested.

For flushing the document history, we might be able to use DynamoDB and setting a TTL or time-to-live property, and expire them after a certain time.

Edit- here's a link to the repo:
https://github.com/rlingineni/y-serverless

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants