Document Persistence: How Many Writers?

I have read as many previous posts as I can find. This thread seems close but not exactly what I need:

Constraint: Cannot use LevelDB
       And: Node.js is running on serverless cloud

Given: 5 users collaborating on the same document
  And: Any/All users can update the document at any time
  And: App auto-saves to persist the document to the database every 2 seconds if there are changes

When: Auto-save detects changes required persistence
 And: App persists changes to database

Then: Latest document changes are persisted to database
  Or: Latent document syncs on various users are persisted to database; overwrite earlier full changes

Questions:

  1. Is it intended for only one user app persists to the database?
  2. Or is it intended that all users persist to the database?
  • If 1: how is it determined which user app should save?

  • If 1: when that user leaves collaboration, how is it determined which user takes over saving?

  • If 2: how are latent document updates prevented from overwriting earlier full document updates?

  • If 2: how are network partitions handled when one or more users miss updates from other users but continue to persist their own updates (basically split brain)?

  • Basically, how do I ensure that all latest document changes are in the database to read when later a 6th user joins in collaboration?

Hey … check out https://github.com/kapv89/yjs-scalable-ws-backend

Thanks, @kapv89. It sounds like what y-level does but on the server-side.

Can this talk to any of our functions (FaaS) so those can communicate with our cloud database?

Does using websockets mean that the Yjs no longer communications updates to all users via TURN server?