GitHub - shadrach-tayo/cloudflare-worker...
I put together a very simple example repo showing a Worker + Durable object + Hyperdrive (Postgres) integration
https://github.com/shadrach-tayo/cloudflare-worker-example
I just recently migrated our Automerge CRDT sync server architecture to use Partykit + Cloudflare workers Durable Object + Hyperdrive (Postgres) with tunnel deployed in our kubernetes cluster.
Happy hacking weekend guys 🎉
GitHub
GitHub - shadrach-tayo/cloudflare-worker-example: An example reposi...
An example repository showcasing how to implement a Cloudflare worker + DurableObjects binding + Hyperdrive (Postgres) integration - shadrach-tayo/cloudflare-worker-example
3 Replies
Very cool! What are you 'syncing'? Do you have replicas in various regions?
The sync server is used to coordinate WebSocket connections between 2 or more clients working on the same Automerge document.
So I migrated this to use cloudflare durable objects to isolate clients by their document ID, kind of similar to isolated chat rooms.
For Automerge this not only helps us scale better (spining up new DurableObject instance for each Automerge document being worked on in realtime to sync up all clients (including our own backend that make calls to get latest version of documents at times),
It also prevents overloading each session with more that one document handle in memory and prevents leaking document between clients connected to the sync server without having to setup authentication in the document share policy (this will introduce frequent network trips to the backend).
Also if a collaborative session crashes the server for a reason it doesn't affect the other sessions as they're all isolated thanks to DurableObjects.
That's fascinating. Thanks for sharing!