Building a realtime collaborative PDF editor in Rust (and why it barely uses any CPU)
I have been working on a collaborative PDF sheet music and score annotation studio for musicians (classical guitarists, violinists, and pianists) and decided to write the backend in Rust. Why? Because I got tired of watching traditional backend runtimes devour half a gigabyte of RAM just to pass some JSON payloads around.
I recently ran a load test on my VPS (which only has one 10 year old core and 2GB of RAM) and wanted to share the results. Spoiler alert: Rust is ridiculously efficient.
The Setup
I built a custom load testing tool to simulate real user traffic pushing heavy CRDT updates. Here is the exact command I ran to benchmark the production server:
./load_tester --url ws://172.19.0.4:7543/ws/ --rooms 100 --users-per-room 2 --duration 60 --rps 2
What do these parameters actually mean?
- url: I am hitting the Docker container directly over WebSockets, bypassing the reverse proxy to get raw performance metrics.
- rooms: We spin up 100 active document sessions.
- users per room: 2 users per room, bringing us to 200 concurrent active musicians simultaneously annotating scores and placing fingerings, bow marks, and measure highlights.
- duration: Sustaining this chaos for a full 60 seconds.
- rps: Each user sends 2 WebSocket updates per second. That is 400 messages per second total across the server, with an average payload size of around 4.8 KB of binary data.
The Results
I tracked client perceived round trip latency and server resource usage. Here is what happened.
Latency (Round Trip)
- Mean: 14.8 ms
- p50: 7.6 ms
- p90: 27.7 ms
- p95: 41.3 ms
- p99: 69.2 ms
For a collaborative score annotation app, anything under 50ms feels like absolute magic. A p99 of 69ms means even the absolute worst network spikes are barely noticeable to a musician drawing with a stylus or dropping fingerings and bow marks.
Server Resource Usage
This is where it gets genuinely funny.
- Peak CPU: 10.5%
- Peak Memory: 358.9 MB
Yes, you read that right. 200 active users syncing complex state at 400 requests per second, and it peaks at roughly 10% of a single CPU core.
Here is a quick visual snapshot of the CPU load during the 60 second test run:
Time CPU% Usage
0s 0.0%
10s 4.9% █████
20s 5.0% █████
30s 6.8% ███████
44s 10.5% ██████████ (Peak!)
50s 6.8% ███████
60s 7.3% ███████
Meanwhile, the memory profile just sat completely flat at 358 MB the entire time. No massive garbage collection pauses. No memory leaks. Just a perfectly flat, boring line.
Taking it to the Extreme
Because the VPS was barely breaking a sweat, I decided to see what happens when you throw real hardware at it.
I ran the exact same backend locally on my M1 MacBook Pro. I cranked the load tester up to simulate tens of thousands of concurrent users spread across 500 active rooms. Even under that absurd amount of load, the latencies were actually lower than the numbers I got on the VPS, and the machine handled it beautifully.
Takeaways
Writing the backend in Rust means I can run this entire collaboration stack on a literal potato server and still have headroom to spare. Honestly, the hardest part of this entire benchmarking process wasn't optimizing the server code; it was figuring out how to generate enough fake traffic to actually make the Rust binary sweat.
I just wanted to share these numbers because seeing a perfectly flat memory profile and sub 15ms latencies brings me an unreasonable amount of joy.
Let me know if you have any questions about the architecture or how I handle the WebSocket syncing!