Why We Built Our Own DNS Infrastructure
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.
Related posts
- Welcome to the Wonderful World of Clusters
Replit mediumAdeptReplit 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.
- HTTPS by default
Replit mediumAdeptReplit's proxy now redirects all HTTP requests to server repls to HTTPS and serves HSTS headers, so every hosted server is HTTPS by default. The proxy manages roughly half a million Let's Encrypt certificates via ACME. It uses HTTP-01 validation for custom domains, which already CNAME to the proxy, and DNS-01 for per-user wildcard certificates (*.<user>.repl.co), so each user needs only one certificate. Certificates are renewed lazily on request once fewer than 30 days remain, about 5,000-10,000 per day. A conservation mode defers renewals when ACME rate-limit capacity runs low, and a circuit breaker forces renewal for certificates near expiry.
- Sharding Infrastructure: The Regional Goval Project
Replit mediumAdeptReplit 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.
- Probing DNS at Cloudflare
Cloudflare mediumAdeptCloudflare extended Flamingo, its Rust-based end-to-end testing framework that runs hundreds of millions of tests a day against the production edge, with a DNS module to catch slow, partial DNS failures that unit tests and health checks miss. Flamingo tests use a setup-action-response DSL, and protocol support is added as modules dispatched through strongly typed Action/ActionOutput enums. Scheduling and reporting are handled by the framework. The DNS probe continuously updates a TXT record with a timestamp and queries three authoritative nameservers and 1.1.1.1 from every data center. It asserts freshness within 90s for the authoritative servers and 600s for the resolver. These results feed SLOs whose error-budget burn rates automatically decide whether a canary release is promoted or rolled back.
- Replit²
Replit mediumAdeptA Replit Nix repl can act as a code-execution backend: a Koa.js server spawns a Python child process and feeds user code through stdin, using code.InteractiveInterpreter, which avoids shell injection and keeps crashes from taking down the server. A second repl works as a proxy that load-balances across forked compute nodes, tracking per-node concurrent calls in Replit Database with a usage threshold and HTML-escaping input. A simple web component front end calls the cluster's API. A security section notes the limits of this sandboxing approach.