Linux and PostgreSQL in the Multiverse of Connections (ver 3)
This talk delivers an analysis of the architectural costs associated with PostgreSQL's process-per-connection model, examining Linux shared memory usage, memory allocation tables, CPU context switching and CFS versus EEVDF scheduling. Talk explains why too many connections become exponentially expensive and degrade performance.
PostgreSQL connections are expensive, and their count is often the limiting factor for performance and stability. Connection pooling is a primary scaling tool for modern systems with microservices, short-lived clients, and bursty traffic. We all know it, but do we really understand why? This talk offers a deep dive into PostgreSQL and Linux architecture, explaining the concrete costs of “too many connections” in PostgreSQL’s process-per-connection model. We will discuss CPU overhead from context switching; kernel resources such as sockets and file descriptors; differences between the classic Completely Fair Scheduler (CFS) and its newer EEVDF-based scheduling approach; limitations of MVCC snapshot implementation across different PostgreSQL versions; accumulation of allocations in per-session memory contexts; and how much memory a query can allocate during execution. We will also look for guidance on “maximum active connections per CPU core” for OLTP vs. OLAP.