Read the original at figma.com ↗figma.com
Figma's infrastructure team faced database scalability challenges as traffic grew 3x annually, with a single PostgreSQL instance hitting 65% CPU utilization during peak hours. Rather than horizontally sharding or migrating to incompatible systems, they chose vertical partitioning—moving table groups to separate databases. The team built a custom zero-downtime migration solution using logical replication and PgBouncer coordination, successfully partitioning tables multiple times in production while maintaining <1 minute availability impact and setting the foundation for future horizontal scaling.
01Key takeaways
- Measure database impact using average active sessions (AAS) and query patterns to identify high-value partitioning candidates strategically.
- Vertical partitioning provides immediate relief while creating a foundation for future horizontal sharding of specific table subsets.
- Use logical replication with reverse replication capability to enable safe rollbacks and minimal-downtime migrations on production systems.
- Coordinate migrations through a connection pooler layer (PgBouncer) to reduce complexity and gain visibility across thousands of client instances.
- Optimize logical replication by removing indexes before bulk data copy and rebuilding after—reducing copy time from weeks to hours.
- Proactively address scalability before saturation becomes imminent; infrastructure teams must identify and fix issues before they threaten availability.
02Key sections
- The scaling problem
- Figma's single RDS database couldn't handle 3x annual traffic growth, reaching 65% CPU utilization at peak times. Read replicas and connection pooling provided temporary relief, but write-heavy workloads still required a longer-term architectural solution.
- Why horizontal sharding wasn't viable
- Figma evaluated horizontally scalable options but rejected them: managed Postgres-compatible solutions posed unknown scaling risks, NoSQL required major application rewrites, and self-hosting would consume too much operational overhead. Vertical partitioning emerged as a pragmatic middle path.
- Identifying tables to partition
- The team used runtime validators hooked into ActiveRecord to measure query impact (via average active sessions) and table isolation. They prioritized moving high-traffic, loosely-coupled table groups to minimize application rewrites and maximize workload relief.
- Building a zero-downtime migration system
- Figma created a custom solution using logical replication and PgBouncer coordination to reroute traffic without maintenance windows. The process pauses connections, synchronizes databases via LSN verification, and reroutes queries—all within ~30 seconds of partial availability impact.
- Logical replication optimization
- Initial logical replication was slow due to inefficient index updates. Removing indexes before copying data and rebuilding afterward reduced copy time from weeks to hours, enabling faster, lower-risk migrations.
- Results and next steps
- Vertical partitioning reduced CPU utilization from 65% to ~10% on the largest partition. The team now plans to introduce a query routing service and eventually horizontally shard high-write tables, leveraging the tooling built for vertical partitioning.
“If our database became completely saturated, Figma would stop working.”Tim Liang · figma.com
“If Figma's infrastructure is a series of roads, we can't just shut down the highways while we work on them.”Tim Liang · figma.com
03Frameworks mentioned
Summary and takeaways written by PM Atlas; quotes are short excerpts. © the original author.