Latest / The CTO Podcast with Fexingo: Technical Leadership, Architecture, and Engineering Org / How Figma's Multiplayer Engine Handles 100k Simultaneous Objects
Transcript
- Lucas: So Figma is famous for multiplayer design — you and a teammate can edit the same file, see each other's cursors, and changes appear in milliseconds. But what happens when that file has 100,000 vector objects and twenty people are all tweaking things at once? Luna: I think most people just assume it works by magic. But under the hood it's a really specific engineering bet they made early on. Lucas: Exactly. And that bet was: don't use operational transforms — the approach Google Docs pioneered — and instead build on conflict-free replicated data types, or CRDTs. Back in 2016, when Figma was still in private beta, that was a contrarian move. OT was the proven path for text-based collaboration. But Figma isn't text — it's a tree of objects with properties like position, rotation, fill color, layer order. Luna: Right, and with OT you need a central server to sequence every operation and resolve conflicts. That becomes a bottleneck when you have hundreds of operations per second. Lucas: Exactly. So Figma's CTO, Evan Wallace — who also co-founded the company — decided to go with CRDTs. Each client maintains its own copy of the document state, and every edit generates a small message that gets broadcast to all other clients. The magic is that the data structure itself is designed so that any set of concurrent edits will converge to the same final state, no matter what order they arrive in. No server-side conflict resolution needed. Luna: But that sounds like it could get chatty. If every keystroke or drag event generates a message, you end up with a lot of network traffic. Lucas: It can. And that's where the engineering gets interesting. Figma doesn't send every single mouse move. They batch messages — they collect all the operations that happen within a 16-millisecond window, which is roughly one frame at 60 frames per second, and send them as a single WebSocket message. That batching reduces the number of messages by about 90 percent compared to sending each operation individually. Luna: And they use WebSocket, not WebRTC? I'd have thought WebRTC would give lower latency. Lucas: Good question. WebRTC is peer to peer and can be faster, but it's also more complex — you have to handle NAT traversal, ICE candidates, all that. Figma decided that WebSocket, with a central relay server, was simpler to debug and more reliable for their use case. The latency is still well under 100 milliseconds for most users, which is fast enough for design work. They also compress the messages with a custom binary protocol — not JSON — to cut bandwidth. Luna: There's another hidden cost with multiplayer: battery life. If you're constantly sending and receiving messages, the laptop fan kicks in. I remember reading that early Figma users on MacBooks were complaining about battery drain. Lucas: Yeah, that was a real issue. In 2018, the team did a deep dive and found that the WebSocket message handling was waking up the CPU too often. They optimized by coalescing updates and reducing the frequency of full-state snapshots. They also moved some of the rendering logic to WebAssembly — compiled from C++ — which is more cpu efficient than JavaScript for the heavy canvas operations. They published a blog post claiming a 40 percent reduction in CPU usage for large files. Luna: And the undo system — that's notoriously hard in a multiplayer CRDT world. How do you undo something someone else did ten seconds ago without breaking everyone else's state? Lucas: Figma's approach is clever. They implement undo as a 'reverse operation' rather than a state rollback. When you hit undo, your client generates the inverse of the operation you just did and sends it as a new operation. The CRDT handles it just like any other edit — it's just another concurrent operation that happens to negate a previous one. The tricky part is that if someone else edited the same object between your original edit and your undo, the reverse operation may not perfectly restore the old state. Figma handles that by tracking a 'version vector' for each object, so the undo only reverses the exact changes you made, not subsequent changes from others. Luna: So it's like git revert versus git reset — you're adding a new commit that undoes the old one, not rewriting history. Lucas: Exactly that. And they store the entire operation history as a log, which also enables the playback feature — 'replay' a file's edit history from start to finish. That's actually a side effect of the CRDT design, not a planned feature initially. Luna: I want to talk about scale for a minute. Figma says some of their largest files have over 100,000 nodes. How does the rendering engine keep up? Even scrolling around a canvas that big can be laggy. Lucas: Right — the multiplayer sync is one piece, but rendering is a whole separate challenge. Figma uses a technique called 'retained mode rendering' with a virtual canvas. They don't draw every object every frame. Instead, they maintain a display list of visible objects based on the current viewport, and only re-render objects that actually changed. For static objects, they cache a bitmap of the visible area and only repaint the dirty regions. That's similar to how video games handle large scenes — frustum culling, level of detail. Luna: And they do all of that in WebAssembly with a custom 2D graphics engine called 'Figma Renderer' — I think it's based on Skia, the same library Chrome uses. Lucas: Yes, they forked Skia and optimized it for their use case. One specific optimization: they batch draw calls. Instead of issuing hundreds of individual draw commands for each shape, they group shapes by their rendering properties — same fill color, same opacity, same blend mode — and draw them all in one pass. That cuts the overhead of GPU state changes dramatically. Luna: So you've got CRDT for state, WebSocket for transport, WebAssembly for rendering, and batching everywhere. It's a full-stack bet on collaboration. Lucas: It is. And it's worth noting that Figma's architecture was designed from day one for multiplayer. They didn't add it later as a feature. That's why they could afford to make radical choices like CRDTs and custom WebAssembly rendering. If you try to retrofit multiplayer onto an existing single-user application, you're looking at a multi-year rewrite. Luna: That's a great point. And if this kind of deep technical breakdown is useful for what you're building or running, we want to keep these conversations ad-free and accessible. The way that works is listener support — if today's episode gave you one concrete idea or a new mental model, you can buy us a coffee at buy me a coffee dot com slash fexingo. It's a small gesture that keeps the podcast independent and focused on the engineering details you actually want to hear. Lucas: Yeah, we really appreciate everyone who chips in. It means we don't have to chase sponsors or dilute the content. Okay, back to Figma — one more thing I find fascinating is how they handle network partitions. What happens if you're on a train and lose connectivity for thirty seconds? Luna: I think they use a local-first approach, right? You can keep editing offline and it syncs when you reconnect. Lucas: Exactly. Because CRDTs are inherently offline-friendly. Every client has a local copy of the document state, and edits are stored in a local operation log. When you reconnect, you send all the operations you accumulated while offline, and the other clients send theirs. The CRDT ensures convergence automatically. There's no conflict resolution dialog — it just works. That's a huge advantage over ot based systems, where offline editing is much harder to implement correctly. Luna: But there's a tradeoff: the local state can become stale if you're offline for a long time. If someone else deletes an object you're editing, what happens when you sync? Lucas: Figma's approach is to keep the deleted object in a 'tombstone' state — it's still in the data structure but marked as hidden. When your offline edit tries to modify that object, the CRDT applies the operation, but the renderer knows not to display tombstones. The object stays in the document model for consistency but doesn't appear visually. Eventually, when the file is saved, tombstones are garbage-collected. But that's a rare edge case — normally, conflicts are so well-handled that users never notice. Luna: So the key takeaway: if you're building a collaborative tool, don't assume you need a central server to resolve conflicts. CRDTs are mature enough now that you can build a fully distributed, offline-capable system. And Figma proved it works at scale with millions of users. Lucas: Right. And the other takeaway is that performance optimization isn't just about the sync layer — it's about the rendering, the network protocol, the batching strategy, and even the choice of language for compute-heavy parts. Figma's engineering team made bold bets early on, and those bets are what make the product feel magical. Luna: If you want to dig into the details, the Figma engineering blog has a great series on their multiplayer architecture, including the exact CRDT algorithm they use. We'll link to it in the show notes. Lucas: And that's our show for today. We're Lucas and Luna, and this is The CTO Podcast with Fexingo.