Read the original at linear.app ↗linear.app
By Linear · linear.app
Linear shares how they built multi-region infrastructure to support GDPR compliance and future scaling. They replicated their entire production deployment across regions rather than sharding, extracted authentication into a global service, and used Cloudflare Workers as a proxy to route requests transparently. The architecture keeps multi-region complexity isolated so engineers can develop features without thinking about regions, while users choose their workspace region only at creation time.
01Key takeaways
- Replicate entire deployments per region instead of sharding to simplify development and avoid cross-region coordination logic.
- Extract authentication into a global service early to enable transparent region routing without changing client or integration code.
- Use infrastructure-as-code from the start to make spinning up new regions straightforward and repeatable.
- Keep multi-region logic isolated to a few subsystems so most engineers never think about regions when building features.
- Implement gradual rollouts with fallback code and feature flags to catch edge cases before full cutover.
- Sync shared data between services using patterns that fit existing conventions: create-first for constraints, async updates for efficiency.
02Key sections
- Why multi-region matters
- Linear identified two drivers: enabling future scaling by isolating workspaces to separate infrastructure deployments, and meeting GDPR compliance needs for European customers who require data residency in Europe.
- Architecture principles
- Linear designed the system so region selection is invisible to users except at workspace creation, and multi-region complexity is isolated to a few subsystems. Engineers should never need to think about regions when developing features.
- Infrastructure as code foundation
- Linear migrated from manual Google Cloud management to Terraform, using GCP's export tooling to codify existing infrastructure, then refactored into modules that accept region as a variable to enable spinning up new regions easily.
- Global authentication service
- A new service knows all user accounts, workspaces, and their region associations. It uses one-way data flow: regional services call it directly, but it schedules background tasks via Pub/Sub to communicate back to regions, keeping deployment simple.
- Data synchronization patterns
- Shared tables between auth and regional services sync via three patterns: create in auth service first to enforce global constraints, delete with Postgres triggers for audit trails, and update asynchronously using existing sync engine logic.
- Request routing with Cloudflare Workers
- A Cloudflare Worker proxy extracts auth info, fetches a signed JWT and target region from the auth service, then routes requests with a pre-signed header. Caching signatures reduces round-trips while supporting long-running WebSocket connections.
“Engineers should never have to think about multi-region when developing functionality for the Linear backend or clients.”Linear · linear.app
“We built it in such a way that while there were of course bugs along the way, most of those were invisible to our users.”Linear · linear.app
03Frameworks mentioned
Summary and takeaways written by PM Atlas; quotes are short excerpts. © the original author.