Distributing Global State to Serve over 1 Billion Daily Requests
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.
Related posts
- Keeping it 100(x) with real-time data at scale
Figma mediumAdept
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.
- Scaling PostgreSQL to power 800 million ChatGPT users
OpenAI mediumAdept
OpenAI serves millions of queries per second for ChatGPT and its API from a single unsharded Azure PostgreSQL primary plus nearly 50 geo-distributed read replicas, despite load growing more than 10x in a year. The approach is to keep the primary as idle as possible: move shardable write-heavy workloads to Azure Cosmos DB and ban new tables, push reads to replicas, kill expensive ORM-generated joins, and isolate high- and low-priority traffic onto separate instances. Supporting measures include PgBouncer pooling (connection time down from 50 ms to 5 ms), cache leasing to stop miss storms, multi-layer rate limiting with query-digest blocking, and schema changes capped at a 5-second timeout. The result is low double-digit millisecond p99 latency, five-nines availability and one SEV-0 in 12 months, and cascading replication is being tested to scale past 100 replicas.
- A Deep Dive into PolyScale’s Architecture
Neon mediumAdept
PolyScale is a wire-protocol proxy cache that sits between an application and its database (here, Neon serverless Postgres), routing connections to the nearest edge PoP and caching query results with TTLs it learns automatically from arrival rate, result change rate and related "query templates". Typically a cache hit happens by the 2nd or 3rd query. Invalidation works in three layers: row-level SQL parsing of writes with global invalidation messages to all PoPs, a table-level fallback for complex queries, and detection of unexplained result changes that disables caching for affected queries, giving eventual consistency without reading the WAL. A built-in performance test shows cached responses around 1ms versus 90–515ms direct to the origin.
- The architecture of Neki
PlanetScale mediumAdeptNeki shards unmodified PostgreSQL behind a single connection string. A Router speaks the Postgres wire protocol, parses and plans queries against the sharding layout, and either pushes joins down to shards or runs cross-shard nested-loop, hash or merge joins itself. Each instance runs a Sidecar that pools connections by lifetime (statement, transaction, session advisory lock) and a PostgresManager. Admin handles failover, pg_rewind and per-shard sync/async/cross-zone durability, while an authoritative shard keeps custom type OIDs consistent and etcd holds the Data Topology. A Replicator built on logical replication drives MoveTables, Reshard and shadow-table OnlineDDL, and the Router buffers retryable queries during cutovers and failovers.
- Let Your AWS Lambdas Survive Thousands of Connections
Neon mediumAdept
Lambda's per-instance database connections can overwhelm Aurora Serverless v2 during traffic spikes, causing connection exhaustion, lingering zombie connections and cold-start latency, and RDS Proxy adds cost, pinning issues and borrow latency without fully fixing it. Neon's alternative is PgBouncer built into every endpoint in transaction pooling mode, enabled by adding '-pooler' to the hostname. It accepts up to 10,000 client connections, multiplexes them onto 64 server connections per user/database pair, and queues requests instead of rejecting them. A walkthrough builds a logistics API with a Postgres schema, node-postgres and the Serverless Framework to exercise the pooled setup.