To learn yjs, I want to build a collaborative scatterplot. A user can create a new session (I.e. a new room) and share the resulting link with others.
There could potentially be a lot of rooms created; so there might be a lot of providers instantiated to the point where the websockets server can’t keep up anymore.
I understand, that the client side provider objects are destroyed once all tabs are closed, that used the object, but the room and doc will still exist on the server. Can those be destroyed after some time of inactivity? Are there other patterns to keep server load in check?
By default, y-websocket does not persist Docs, so as soon as you kill the server the Docs will be deleted (and if no clients are connected, they will be permanently deleted).
If you are using a provider for persistence, they will typically have a deleteDocument or clearDocument function that allows you to delete a Doc (i.e. room). It’s up to you to manage when/how rooms get deleted from storage.
The YPERSISTENCE feature that is built in to y-websocket uses y-leveldb, so you can delete rooms by importing getPersistence and then calling persistence.clearDocument.
I don’t really have experience with how quickly server-load is growing when just keeping the server running for a while. It might also be valuable to keep the rooms alive for all eternity!
However, sooner or later the admin would have to power-cycle the server or have some cleanup-functionality to keep server-load at a reasonable level.