You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Every perform_update call (document save) makes a synchronous, blocking HTTP call to the collaboration server before it can proceed. The same applies to the can_edit endpoint. This means:
Every save adds the round-trip latency of the collaboration server
If the collaboration server is slow or unreachable, the entire request hangs for up to 10 seconds (the timeout=10)
If the cache is empty, the requests are blocking so mainly the first time the user try to connect
If the cache is not empty, request is unblocking and leaded by the cache, ⚠️ in the same time, we re-trigger a cache update in background (_can_user_edit_document)
Tip
can-edit is usually called before perfom_update by the frontend, increasing the chances that perfom_update will be ever unblocking.
Other way
Note
We could as well imagine a totally different way to save content !
During a save:
frontend does a http request on the collaboration server instead of the django server
collaboration server check if the condition are respected:
user is connected to the collab-server
if not if he is alone
Only collaboration server will trigger the save to the django server.
The Problem
Every
perform_updatecall (document save) makes a synchronous, blocking HTTP call to the collaboration server before it can proceed. The same applies to thecan_editendpoint. This means:timeout=10)docs/src/backend/core/api/viewsets.py
Lines 729 to 733 in cbe6a67
docs/src/backend/core/services/collaboration_services.py
Lines 58 to 62 in cbe6a67
Possible solution
We could improve the pattern to be more optimistic, and less blocking.
2 endpoints call _can_user_edit_document:
We could use a cache that last about 15mn:
Tip
can-editis usually called beforeperfom_updateby the frontend, increasing the chances thatperfom_updatewill be ever unblocking.Other way
Note
We could as well imagine a totally different way to save content !
During a save:
Only collaboration server will trigger the save to the django server.