Latest / The CTO Podcast with Fexingo: Technical Leadership, Architecture, and Engineering Org / How Figma Built a Real-Time Multiplayer Design Engine
Transcript
- Lucas: If you've ever been in a Figma file with a dozen other designers, you've experienced something that shouldn't technically work — multiple people dragging vectors, changing layers, adding comments, all in real time, inside a browser window. It feels simple, but the engineering behind that is genuinely wild. Luna: I remember the first time I saw two designers editing the same rectangle — their cursors were both active, and the shape was morphing in real time. I thought, 'How is the browser not melting?' Lucas: Right. And the answer is that Figma built a custom real-time sync layer that sits somewhere between Operational Transform and CRDT territory. Actually, a lot of people assume they use a standard CRDT library — they don't. They built their own, specifically for vector graphics. Luna: Why not just use something like Yjs or Automerge? Those are battle-tested for text. Lucas: Great question. Those libraries are optimized for linear text — think Google Docs. But Figma's data model is a tree of vector paths, fills, strokes, effects, constraints. A designer might be editing a bezier curve handle on one layer while someone else is reordering layers in the panel. That's not a linear text document. So Figma's engine models the entire document as a graph of immutable operations, each one timestamped and assigned to a user. Luna: So every stroke, every color change, every bounding-box resize — that's an operation that gets sent to all connected clients? Lucas: Exactly. And the key innovation is how they handle conflict resolution. If two designers change the same property at the same instant, Figma uses a deterministic merge rule — typically last writer wins, but with a twist: they track causal history. So if your operation happened after mine in logical time, even if mine arrived at the server first, yours wins. It's a hybrid of OT and CRDT ideas. Luna: What about performance? I've seen files with hundreds of layers and dozens of users — the renderer has to keep up. Lucas: That's where WebGL comes in. Figma initially used WebGL 1, but around 2021 they migrated to WebGL 2 for better batching and instanced rendering. The renderer doesn't redraw the entire canvas every frame — it maintains a dirty-rect list: only the regions that actually changed get recomposited. And they do that at 60 frames per second, even on mid-range laptops. Luna: But doesn't WebGL have limits on how many draw calls you can make per frame? Lucas: It does. So Figma batches all vectors that share the same material properties — same fill, same opacity, same blend mode — into a single draw call. They've published that a typical complex frame might be rendered in under 30 draw calls, whereas a naive approach could require thousands. That's the difference between a smooth 60 fps and a stuttering slideshow. Luna: Speaking of smooth — let's talk about the offline experience. Figma added offline support a couple years ago. How does that work with a real-time engine? Lucas: The offline mode is essentially a local-first replica of the document. When you go offline, the client caches the full operation log locally. Every edit you make gets appended to a local pending queue. When you reconnect, the client replays those operations against the server's current state, and the server reconciles any conflicts. Figma uses a technique called 'operation squash' to compress multiple local edits into a single delta before sending. Luna: So if I'm offline for an hour and make 200 changes, it doesn't send 200 individual operations? Lucas: Exactly. It merges them into a single operation that represents the net effect. That's crucial for bandwidth — and for avoiding 'edit storms' that could overwhelm the server. Figma's server infrastructure is built on Go and Rust, by the way. The sync layer itself is Go, the rendering backend is Rust via WebAssembly for some compute-intensive tasks like font rasterization. Luna: That's a really interesting stack choice. Most people think of Figma as a frontend tool, but the backend complexity is enormous. Lucas: It really is. And speaking of what makes this kind of deep-dive possible — I want to mention something briefly. This show is ad-free, and it stays ad-free because a small number of listeners chip in to support it. Honestly, it's not a big ask — just that if you find these technical breakdowns useful for what you're building or running, you can find us at buy me a coffee dot com slash fexingo. Luna: Yeah, and it genuinely makes a difference. We get to go deep on topics like Figma's rendering engine without worrying about sponsors or ad reads. So if you're someone who values that, it's a way to keep it going. Lucas: Alright — back to the rendering pipeline. One of the hardest problems Figma solved was text rendering inside the WebGL context. Browsers handle text natively via the DOM, but Figma doesn't use DOM for the canvas — it's all WebGL. So they had to build a custom text layout engine that supports OpenType features, kerning, ligatures, right-to-left scripts, all inside a shader. Luna: Wait — they're rasterizing glyphs on the GPU in real time? Lucas: Yes. They pre-bake glyph atlases for commonly used fonts, but for rare or custom fonts, they render them on the fly using a technique called 'signed distance field' text. The GPU can render crisp characters at any size from a single small texture. That's how you can zoom in 800% and the text stays sharp. Luna: That explains why Figma feels so much smoother than, say, an svg based editor at high zoom levels. Lucas: Exactly. And the collaboration layer is built to handle that zoom level independently per user. Each client maintains its own viewport — so one designer can be zoomed into a button while another sees the full page layout. The sync engine only sends operations about the document state, not about viewport position. That's a huge optimization. Luna: So the server never knows where anyone is looking — it only knows what they changed. Lucas: Right. The cursor positions are broadcast peer to peer via WebRTC, not through the server. That's why you see other users' cursors move smoothly even if the server is under load. Figma uses a mesh of WebRTC connections for presence and cursor data, while operations flow through the central server for ordering. Luna: Clever separation of concerns. One operation channel for authoritative state, one peer to peer channel for ephemeral stuff. Lucas: And that design is what allows Figma to scale to hundreds of simultaneous editors in a single file. In 2022, they published a case study about a design team at a major tech company that had 150 people in one file during a sprint review. The system handled it. Luna: Did they have to throttle anything at that scale? Lucas: They use a technique called 'operation batching' — the client doesn't send each individual mouse move as an operation. Instead, it samples the mouse position at 30 Hz and sends deltas. For property changes, they debounce aggressively: if you're dragging a slider that adjusts a shadow blur, they send the final value, not every intermediate step. Luna: That's exactly what you'd want — you don't need to know that the blur went from 0 to 10 through every integer. Lucas: Exactly. And the server side uses a technique called 'operation queue per document' — all operations for a given file go through a single-threaded event loop, which guarantees total order. No locks, no distributed consensus. It's simple but effective because the load per document is manageable. Luna: What about the 'onboarding cliff' that enterprise teams face? When you go from a small design team to 50+ designers in one file, do they hit any hidden bottlenecks? Lucas: Great observation. The biggest bottleneck is actually the initial load. When you open a large file, the client has to download the full operation history — or at least the compressed snapshot. Figma generates snapshots periodically — every few hundred operations — so a new client can start from the latest snapshot and only apply the delta since then. But if the snapshot is huge, it can take seconds to download. Luna: How do they handle that without making the user stare at a loading spinner? Lucas: They stream the data in chunks — the canvas renders progressively. You see the main shapes first, then text layers, then effects like shadows. The user can start interacting before the file is fully loaded. They also cache snapshots in a CDN, so repeat opens are fast. And they compress the binary format using a custom scheme — they wrote about achieving 10x compression over JSON. Luna: That's impressive. I think the key takeaway here is that Figma made a series of deliberate engineering trade-offs: building a custom CRDT instead of using an off-the-shelf library, separating operation data from presence data, and designing a progressive loading system. None of that is accidental. Lucas: And it's why after a decade, there's still no real competitor that matches the real-time collaboration experience in a browser. The moat is the engineering. So the next time you're in a Figma file and you see someone else's cursor moving, remember there's a whole custom sync engine and a gpu based renderer making that happen. Luna: And supporting this show helps us keep bringing you those technical deep dives. If you found this useful, you know where to find us. Lucas: Thanks for listening, and we'll see you next time.