• 2 min read

DocSync

A real-time collaborative editor for notes, code and canvases, built on Yjs with a Postgres-backed WebSocket gateway and load-tested on AWS.

YjsWebSocketsNode.jsPostgreSQLRedisAWS ECS

DocSync editor

What it is

A shared workspace where several people edit the same page at once. A page can mix rich text, checklists, code blocks (CodeMirror) and tldraw canvases. You see other people’s cursors and presence, and you can leave comments and mentions.

  • Sharing. New pages are private. You invite people as owners, editors or viewers. The server enforces viewer permissions, so hiding the edit buttons isn’t the only thing stopping a viewer.
  • History. Edits are grouped into 30-second entries. You can compare an entry with the one before it and restore an old version without losing what came after.
  • Assistant. You can ask Gemini about the page or ask it for a change. Suggested edits show up as a diff and only apply after you approve them.
  • Background jobs. PDF export, search indexing and link previews run in a separate BullMQ worker.

How it works

The client is React and Vite. Every edit is a Yjs update sent over a WebSocket to a Node gateway. The gateway authenticates the user, checks their role, validates the update and saves it to Postgres. Only then does it publish the update to Redis, which fans it out to the other gateway replica and on to the other browsers.

Saving before broadcasting means reconnects, replay and version restore all work from the same durable sequence, whichever replica a client lands on.

Locally it runs in Docker Compose: Nginx, two gateways, a worker, Postgres, Redis, Prometheus, Grafana and Jaeger. On AWS, Terraform sets up a load balancer, two ECS Fargate gateway tasks, RDS Postgres, ElastiCache Redis, ECR, Secrets Manager and CloudWatch.

AWS architecture

Results

I brought up a short-lived AWS staging environment in us-east-2, ran the benchmarks, and tore it down. Each client authenticated and sent real Yjs updates (3 edits each), and a run passed only if every client ended on the same document state. The times below measure how long an edit took to reach the other clients:

ClientsEditsp50p95p99Converged
2575561 ms1,140 ms1,238 ms25/25
501501,119 ms2,029 ms2,138 ms50/50
1003003,555 ms5,645 ms5,979 ms100/100

All three runs had zero connection errors. Propagation time grows quickly with the number of clients on one page.

I also stopped one gateway task in the middle of a workload. With 8 clients and then 16, ECS replaced the task and every client converged. The surviving gateway kept the sockets open, so no client had to reconnect. That means the AWS run doesn’t test reconnects. A local chaos run does: 8 edits accepted, 8 saved, 0 lost, 0 duplicated, one client reconnected, and the document converged.

The server has 113 tests covering auth, roles, persistence, fan-out, recovery, invitations and concurrent edits.

Limits

  • The AWS environment used a single-AZ database and one Redis node, sized for testing.
  • I haven’t measured more than 100 clients on one page.
Back to top