Keeping it 100(x) with real-time data at scale
Figma rebuilt LiveGraph, its real-time GraphQL-like subscription service over Postgres, to scale reads and database update load 100x as the database moved from one instance to vertical and horizontal shards. The old design tailed a single globally ordered replication stream into per-server mutation-based caches, which caused excessive fan-in and fan-out, fragmented caches, thundering herds on deploy, and stalled optimistic updates whenever any shard blipped. Two traffic findings drove the redesign: most data is delivered by initial reads rather than live updates, and most queries can be invalidated directly from a row mutation. The result is a three-tier Go system: an edge that expands views, a read-through cache sharded by query hash, and stateless invalidators sharded like the databases that tail the replication streams and send invalidations only to the relevant cache shards.
Related posts
- GraphQL, meet LiveGraph: a real-time data system at scale
Figma mediumAdept
LiveGraph is Figma's real-time data layer on Postgres: frontend code declares GraphQL-like live queries via a React useSubscription hook, and the server keeps results updated by tailing the Postgres write-ahead log distributed over Kafka instead of polling. Each view is decomposed into a tree of join-free single-table subqueries. An index of active subqueries routes replication-stream changes to the right cached results, and subqueries are shared across users to cut database load. The client is isomorphic with the NodeJS server and receives ordered, exactly-once incremental updates, with permission checks and optimistic updates built in. Performance-critical parts are written in Go, a single instance currently handles about 10,000 writes/second, and open problems include sharding, thundering-herd reconnects after deploys, and pagination of live views.
- How Figma’s databases team lived to tell the scale
Figma mediumAdept
Figma horizontally sharded its RDS Postgres stack after vertical partitioning ran out of room. Multi-terabyte tables were hurting vacuum reliability and approaching RDS IOPS limits. Instead of moving to CockroachDB, TiDB, Spanner, Vitess or NoSQL, the team built sharding on its existing Postgres fleet using several pieces: colocated table groups ("colos") that share a shard key such as UserID, FileID or OrgID; hash-based routing to avoid hotspots from auto-incrementing and Snowflake IDs; logical sharding via views, kept separate from physical shard splits; and a DBProxy query engine that parses and routes queries and also does load-shedding and request hedging. Deliberate tradeoffs included dropping atomic cross-shard transactions, accepting slower range scans, keeping rollback possible, and using full logical replication. Sharding the first table took nine months.
- Speeding up file load times, one page at a time
Figma mediumAdept
Figma extended dynamic page loading from view-only files and prototypes to editable files, cutting load times for the slowest 5% of loads by 33% and reducing client memory. Editing requires write dependencies as well as read dependencies. These are the inverse edges that let an edit to a component, style or variable propagate to cached derived data on instances and auto layout frames, which may sit on unloaded pages. The QueryGraph dependency framework in the multiplayer server became a bidirectional graph with explicit foreign-key edges and implicit edges such as auto layout. The server uses it to compute each session's reachable subset as collaborators edit, and a shadow-mode validator flagged edits outside the computed write set, uncovering missed cross-page dependencies before launch.
- Distributing Global State to Serve over 1 Billion Daily Requests
Render mediumAdept
Render's request routers evolved from per-instance in-memory caches with 5-minute TTLs and database lookups on miss, which overloaded PostgreSQL on every redeploy and failed during database downtime, to push-based caching using PostgreSQL LISTEN/NOTIFY so routers never query the database in the hot path. That change cut p99 routing time to under 4ms and propagated updates in under a second. Going multi-region exposed database connection limits and slow router startup, fixed by adding per-cluster shared cache instances that serve snapshots, record fetches and WebSocket update streams. Routers pin to a single cache to avoid inconsistent state, and startup in distant regions fell from over a minute to under twenty seconds.
- 100x Faster: GraphQL Hive migration from Elasticsearch to ClickHouse
ClickHouse easyNovice
GraphQL Hive replaced Elasticsearch with ClickHouse for storing per-request GraphQL monitoring data (consumer, requested fields, latency, request body) after query latency degraded with data growth and one large tenant slowed queries for smaller ones. On a 20M-row benchmark where one user owned half the rows, percentile queries took ~10s on Elasticsearch, ~5s on InfluxDB (which struggled with high cardinality), ~3s on TimescaleDB and ~100ms on ClickHouse. Druid was skipped as too complex. Because data had a 30-day TTL, the team dual-wrote to both stores for a month and then switched reads with zero downtime, reporting a 100x average improvement and growth from millions to billions of rows per month. They are now moving to ClickHouse Cloud for sharding and replication.