OpenAI - Scaling Postgres
From: https://openai.com/index/scaling-postgresql/ Properly Scaling /PostgreSQL is important as it can be easy to overload if we are not careful Currently it supports millions of queries per second. Architecture A single primary for writes and a lot of secondary replicas for reading data (Azure PostgreSQL) For read-heavy load, scaling is good, but write heavy load can be an issue PostgreSQL’s Multi Version Concurrency Control (MVCC) Code optimized to minimize writes Shardable data moved to another service - Azure Cosmos DB (noSQL database) Postgres remains unsharded. Challenges Faced and Optimizations Reduce Load on Primary Offload read traffic to replicas whenever possible Only read queries part of a write transaction are run on primary. Writes If Shardable To Azure CosmosDB if not Optimize the queries Remove redundant writes introduce lazy writes when backfilling (say: adding new columns) put rate limits Query optimization The good old ...