Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Replit 5 min read Case study mediumAdept

Welcome to the Wonderful World of Clusters

Replit split its infrastructure into multiple independent clusters (failure domains) after two load-related site-wide outages, moving paid Hacker users into their own cluster so future incidents affect only a subset of users. A cluster resolution service exposed as an external DNS server maps repls to clusters for both the web server and `.repl.co` hosting, adding no extra lookup latency. Because DNS answers are cached, users moved between clusters leave tombstones in the old cluster that transparently proxy connections to the new one until the record's TTL expires. The new cluster also became a tool for shedding load during incidents and lets Replit run Hacker repls on beefier machines.

Related posts

  • Why We Built Our Own DNS Infrastructure

    Replit mediumAdept

    Replit made its repl hosting cluster-aware by running its own authoritative DNS server for *.repl.co, which resolves each repl's domain to the proxy load balancer in the cluster hosting that repl. This avoided a "meta-proxy" layer that would have added two extra hops per request. The Go server, built on miekg/dns, CNAMEs ACME DNS-01 challenges to a GCP-managed validation zone. Because DNS caching can outlive the 60s TTL, proxies in the old cluster use tombstones to transparently forward requests for repls that have moved. Custom domains work unchanged because they already CNAME to <repl id>.repl.co.

  • Sharding Infrastructure: The Regional Goval Project

    Replit mediumAdept

    Replit re-sharded the infrastructure that runs Repls (Goval) from a few unbalanced, multi-region clusters partitioned by user membership into uniformly sized, single-region clusters with Repls distributed by consistent hashing, shrinking failure domains and removing cross-region traffic. The clusters are now defined with CDK for Terraform in TypeScript as reusable modules, replacing a monolithic Terraform state, codegen tooling and Ansible-managed config, so clusters (including single-tenant ones in separate GCP projects) can be provisioned on demand. Migration happened with no downtime: new Repls were created in new clusters, existing Repls were lazily transferred on connection behind feature flags with rollback capability, and old clusters were deprovisioned while untransferred Repls stayed in storage.

  • Data Loss: a sad tale with a happy ending

    Replit mediumAdept

    Replit silently lost or corrupted user repl data for months. The root cause was a combination of three things: Go's exec.Cmd connecting stdin/stdout directly to child processes, a filesystem snapshot tool that ignored rare failures in its final write(2)/splice(2) calls under heavy load, and low disk space. Together these truncated snapshot streams without raising any error. The team reverted the triggering deploy, added monitoring at suspected loss points, salvaged corrupt data on load, validated snapshot output before persisting, and ran a batch Dataflow pipeline over old repls. Afterwards they refactored snapshotting and Operational Transformation history persistence, which made repls both more reliable and faster to load.

  • More Reliable Connections to Your Repls

    Replit mediumAdept

    Replit split reverse WebSocket proxying out of Conman, its container manager on GCE VMs, into a dedicated service called Eval that sits between clients and Conman VMs. Previously, frequent Conman rollouts could disconnect a client twice (once when the proxying VM died and again when the target VM died), complicated autoscaling, and blurred the cause of session failures. With Eval, Conman updates cause at most one disconnect, Eval drains connections with a 30h+ shutdown grace period, scales independently on active connections, and its observability pinpoints whether failures come from token validation, Controlplane lookups or the remote Conman connection.

  • Keep the monolith, but split the workloads

    incident.io mediumAdept

    A Go monolith can get much of the reliability isolation of microservices by splitting workloads into separate deployments of the same binary, instead of breaking it into services. After a bad Pub/Sub message caused an unhandled panic that crashed the web, worker and cron threads together for 32 minutes, incident.io split them into independent Heroku dyno tiers selected by command-line flags. They also gave each class of work its own capped Postgres connection pool and statement timeout, so low-priority jobs such as BigQuery event export or best-effort nudges fall behind rather than exhausting the shared database. The main migration hazard is code that assumes a shared process, such as process-local caches, and the fix is to move that coordination into Postgres or Redis.

The quest for software engineering knowledge.

Look:
Layout: