How OpenAI Scaled to 800 Million Users With Postgres
OpenAI scaled PostgreSQL to handle millions of queries per second for 800 million ChatGPT users using a single-primary architecture with read replicas. Their approach focused on three pillars: minimizing primary database load through read offloading and write optimization, query and connection optimization using PgBouncer for connection pooling, and preventing cascading failures with cache locking and rate limiting. They addressed PostgreSQL's MVCC constraints by migrating write-heavy workloads to sharded systems and enforcing strict schema change rules. The system achieves five-nines availability with low double-digit millisecond p99 latency through systematic optimization rather than sharding.