WORKINGCHAPTER 16

Connection handling, pooling and the process model

Why 2000 connections make Postgres slower than 50, what PgBouncer does about it, and what transaction pooling quietly breaks

55 MINDATABASESUPDATED 2026-11-02
PREDICT

A Postgres 12 server runs 48 busy clients doing point reads at about one million transactions per second. You open 10,000 more connections and leave them completely idle: no queries, no transactions. What happens to the 48 busy clients?

Every client that talks to Postgres gets its own operating system process. That one design decision explains the memory bill, the connect latency, the famous too many clients error, the throughput collapse under thousands of connections, and the existence of PgBouncer. This chapter follows a connection from the TCP handshake to the pool slot and back, then measures the collapse and the recovery on the shop database.

One process per connection

The parent Postgres process is the postmaster. It listens on port 5432, and when a client connects it calls fork(). The child is a backend, and it serves that one client for the life of the connection. Backends share memory with the postmaster, which is where shared_buffers, the lock tables, the WAL buffers and the process array live. Everything else a backend needs, it allocates privately.

The cost of a new connection comes in three parts:

  1. Fork. Copying the process is fast on Linux (copy-on-write), but it is not free: a fresh backend has to map the shared memory segment and set up its own memory contexts. Tens to hundreds of microseconds on a quiet machine, more under load.
  2. Authentication. With scram-sha-256, the default password_encryption since Postgres 14, the handshake is two extra round trips on top of the TCP handshake. Add TLS and it is one or two more. Over a 1 ms link that is 3 to 6 ms before the first query is sent.
  3. Cold caches. A backend keeps private copies of the catalogue rows it has looked up (the relation cache and the catalogue caches). A new backend has none. Its first query on each table pays for the catalogue lookups that an old backend answers from memory. On a schema with hundreds of tables this is where the “first request after deploy is slow” complaint comes from.

Put together, a connect costs a few milliseconds of latency and a few megabytes of RAM. Brandur Leach puts a fresh backend at around 5 MB, growing with what it touches. Freund’s measurements with huge pages enabled put the overhead under 2 MiB for many workloads. Either way, 2000 backends is gigabytes before any of them runs a query, and the shared memory grows too: Freund measured 16,804 MiB of shared memory at max_connections = 100 versus 21,463 MiB at max_connections = 100000 with the same 16 GB of shared_buffers, because the lock tables and the process array are sized up front.

The lesson for the connect cost is in the lab: pgbench -C, which opens a new connection for every transaction, runs an order of magnitude slower than the same workload on persistent connections. That ratio is the reason every application keeps a pool.

Why 2000 connections collapse throughput

max_connections defaults to 100. The number is not arbitrary. Three separate costs grow with the number of backends, and two of them grow even when the backends are idle.

Snapshots. Every statement in READ COMMITTED, and every transaction in REPEATABLE READ, starts by building a snapshot: the set of transaction ids that were running when it started, so MVCC can decide which row versions it may see. The function is GetSnapshotData(), and until Postgres 14 it walked the shared process array, one entry per backend, under a lock. More backends, longer walk, more time under ProcArrayLock. Freund’s benchmark on Postgres 12 isolates it cleanly. Idle connections, 48 active clients, read-only pgbench on a 20-core workstation:

idle connections TPS of the 48 active clients
0 1,032,435
100 960,847
1,000 902,109
2,500 759,723
5,000 702,680
10,000 521,558

A CPU profile of one active connection next to 5,000 idle ones showed the time almost entirely inside GetSnapshotData(). Postgres 14 changed the data structures (dense arrays of xids, and tracking of the oldest xmin so idle backends drop out of the scan), and the follow-up post shows the curve flattening. The penalty is smaller now; it is not gone, and most fleets still run older releases somewhere.

Lock and cache-line contention. When the connections are not idle but active, the picture is worse and older. The Postgres wiki’s page on connection counts, written from benchmarks around version 9.x, describes it: more processes competing for spinlocks, more processes evicting each other’s cache lines, and in one profiled run 10 percent of CPU time spent on a one-byte no-op instruction that was waiting for a cache line. Freund’s own read-only pgbench peaked at around 48 clients on a 20-core, 40-thread machine; past that, adding clients added nothing and then started to subtract.

Context switching. Each backend is a process the kernel scheduler has to run. With 2000 runnable backends on 16 cores, every core switches between 125 processes. Each switch saves and restores registers, flushes some of the TLB, and refills the L1 cache with the new process’s working set. The wiki’s summary holds up: completing 10,000 transactions is faster at 10 or 20 at a time than at 500 at a time, because the work per transaction is the same and the overhead per transaction is not.

The shape you will measure in the lab is the same one Brandur saw and the one every team hits when they raise max_connections to make an error go away: throughput rises with concurrency up to roughly the number of cores, flattens, and then falls while p99 latency climbs by an order of magnitude. The database is not doing more work. It is doing the same work with more overhead, and queueing the rest.

What a pooler does

A connection pool solves this by lying to the application. The application opens as many connections as it likes, to the pooler. The pooler keeps a small, fixed number of real connections to Postgres and hands them out as needed. Hundreds of client connections become 20 server connections, so Postgres runs at the concurrency that suits it while the application keeps the programming model it had.

40 podsapp pool max = 10 each400 client connectionsPgBouncerpool_mode = transactiondefault_pool_size = 16Postgres16 backends busymax_connections = 100hundreds, mostly idle16, all busy

PgBouncer is the standard pooler for Postgres. It is a single-threaded, event-driven process that speaks the Postgres wire protocol on both sides. A client connection costs it a few kilobytes rather than a few megabytes, and it can hold tens of thousands of them. Its one-threadedness is also its limit: one PgBouncer saturates one CPU core at somewhere in the tens of thousands of transactions per second, after which you run several instances on the same port with so_reuseport = 1 and let the kernel spread clients across them.

The setting that matters most is pool_mode, and it has three values:

mode server connection is held what works when
session from client connect to client disconnect everything the default; you want fewer backends but the app relies on session state
transaction from BEGIN to COMMIT/ROLLBACK (one statement if autocommit) anything confined to a transaction the mode that actually multiplexes; what you want for web services
statement one statement single-statement autocommit only; multi-statement transactions are refused PL/Proxy style sharding; almost never otherwise

Session mode gives you almost nothing over connecting directly: a client that is connected but idle still owns a backend. It saves the connect cost (PgBouncer keeps server connections warm and runs server_reset_query, by default DISCARD ALL, before reusing one) and it lets you cap backends, but the 400 idle client connections in the diagram would need 400 backends. Transaction mode is where 400 clients share 16 backends, because at any moment only a few of them are inside a transaction.

What transaction mode breaks

Transaction mode works by handing the next transaction to whichever server connection is free. Two transactions from the same client can run on two different backends. Anything that lived on the first backend is not there for the second. The PgBouncer feature table marks these as never working in transaction pooling:

  • SET and RESET of session parameters.
  • LISTEN (the notification arrives on a backend you no longer hold).
  • WITH HOLD cursors.
  • SQL-level PREPARE and DEALLOCATE.
  • Temporary tables with ON COMMIT PRESERVE ROWS or DELETE ROWS (they belong to the backend session).
  • LOAD.
  • Session-level advisory locks (pg_advisory_lock). Transaction-level ones, pg_advisory_xact_lock, are fine.

SET deserves a closer look because it fails silently. Postgres reports a handful of parameters back to the client when they change, and PgBouncer tracks those per client and replays them: client_encoding, DateStyle, TimeZone, standard_conforming_strings, application_name, plus whatever you list in track_extra_parameters. Everything else, SET work_mem = '256MB' or SET search_path = tenant_42 or SET statement_timeout = 0, is applied to the server connection you happened to hold and stays there for the next client. In the best case your setting disappears on your next transaction. In the worst case another tenant’s query runs with your search_path. The fix is SET LOCAL inside the transaction, which Postgres reverts at COMMIT, which is the only moment PgBouncer hands the connection on. server_reset_query does not help here: it runs in session mode on client disconnect, and in transaction mode it is not run at all unless you set server_reset_query_always = 1, which costs a DISCARD ALL round trip per transaction.

Prepared statements were the longest-running casualty. Almost every driver (JDBC, npgsql, pgx, node-postgres with named statements, psycopg 3, Rails) uses protocol-level prepared statements by default, and the prepared statement is a per-backend object: Parse it on one connection, Bind it on another, and you get ERROR: prepared statement "S_1" does not exist. For a decade the answer was to turn prepared statements off in the driver (prepareThreshold=0 in JDBC, prepared_statements: false in Rails, default_query_exec_mode in pgx) and lose the parse savings. PgBouncer 1.21.0 (October 2023) added tracking of protocol-level prepared statements: it keeps a per-client table of named statements and makes sure each one exists on whichever server connection the transaction lands on, re-sending the Parse if it does not. It is controlled by max_prepared_statements, the number of statements it will track per server connection. It shipped off by default (0); 1.24.0 (January 2025) turned it on with a default of 200. Two caveats remain: SQL-level PREPARE is still unsupported, and 1.22.0 added DEALLOCATE ALL and DISCARD ALL passthrough while a plain DEALLOCATE name still fails. If your PgBouncer is older than 1.21, no setting fixes it.

Sizing the pool

How many server connections should the pool hold? Smaller than you think. The number that gets quoted is from the Postgres wiki and is repeated by HikariCP’s pool-sizing page:

connections = (core_count * 2) + effective_spindle_count

Core count is physical cores, not hyperthreads. Effective spindle count is the number of disks that are actually seeking: zero if the working set fits in cache, up to the real number of spindles if every query goes to disk. A 4-core server with a cached working set gets 8 to 10 connections. The wiki itself notes the formula has not been analysed for SSDs, which have no spindles and deep queues; in practice people treat an NVMe drive as a handful of spindles and land at 2 to 4 times the core count. Freund’s read-only peak at around 48 clients on 20 cores is the same number from a different direction.

Oracle’s Real-World Performance group showed the same shape with a video that HikariCP’s page links: a load test taken from 2048 connections down to 96, response time falling from around 100 ms to around 2 ms, with no other change.

Where the formula fails:

  • Waiting inside transactions. The formula assumes a connection is either running a query or back in the pool. If your code calls a payment API while holding a transaction open, that connection contributes nothing to database throughput and you need more of them. The better fix is to not hold the connection across the call. Brandur calls this a minimum viable checkout: take a connection, do the database work, release it, then do the slow thing.
  • Mixed workloads. Ten reporting queries that run for 30 s each will occupy ten of your sixteen slots and the web requests queue behind them. HikariCP’s advice is two pools, one per workload, each sized for its own job. With PgBouncer you do this with two [databases] entries pointing at the same database with different pool_size.
  • Pool-locking deadlock. If a single request thread needs two connections at once (nested transactions, a query inside a cursor loop), a pool smaller than threads * (connections_per_thread - 1) + 1 can deadlock with every thread holding one and waiting for a second. The right fix is one connection per thread, not a bigger pool.
  • The pooler’s own connections. PgBouncer holds default_pool_size connections per user and database pair, plus reserve_pool_size, plus min_pool_size. Three users times two databases times 20 is 120 backends from one pooler. Count them.

Postgres also needs headroom above the pool. superuser_reserved_connections (default 3) keeps slots for superusers, and Postgres 16 added reserved_connections for roles granted pg_use_reserved_connections, so the on-call engineer can get in when the pool has taken everything else. Buttondown’s postmortem is about not having that slot.

Two layers of pool

In practice there are two pools, and they fail in different ways.

The application-side pool lives in the process: HikariCP (maximumPoolSize, default 10), node-postgres Pool (max, default 10), SQLAlchemy’s QueuePool (pool_size 5 plus max_overflow 10), Rails (pool, default 5), pgx (max_conns, default 4 or the CPU count). It exists to avoid the connect cost and to bound the process. Its invariants are the ones in the connection-pool lesson: never exceed max, and every acquire ends with a connection or a timeout. Its sizing problem is multiplication. 40 pods times 10 is 400 backends, and a deploy that runs old and new pods side by side doubles it for a minute. That minute is when too many clients happens.

PgBouncer sits between the pods and Postgres and turns the 400 into 16. Keep the application pools; make them point at PgBouncer, and consider lowering their max so a pod cannot flood PgBouncer’s max_client_conn (default 100, raise it to thousands). Run PgBouncer close to the database, one or more instances, so the client-to-pooler hop is cheap and the pooler-to-database connections stay warm. Watch SHOW POOLS on its admin console: cl_waiting is clients queued for a server connection, and maxwait is how long the oldest of them has waited in seconds. A rising maxwait means the pool is too small or the queries are too slow; query_wait_timeout (default 120 s) is when PgBouncer gives up and disconnects the waiting client with an error rather than letting it hang.

Idle in transaction

The connection that does the most damage is the one that is doing nothing. A client runs BEGIN, executes a statement, and then waits: on a lock in its own code, on a network call, on a developer who opened psql and walked away. Postgres shows it in pg_stat_activity as idle in transaction. It holds a backend, in every pool mode including transaction mode (the transaction never ended, so PgBouncer cannot reassign the server connection). It holds every lock it took, so a later ALTER TABLE queues behind it and every query queues behind the ALTER. And if it took a snapshot under REPEATABLE READ, it holds back vacuum for the whole cluster, which is the bloat you reproduce in this module’s project.

Postgres has a knob for it, off by default:

ALTER SYSTEM SET idle_in_transaction_session_timeout = '60s';
SELECT pg_reload_conf();

After 60 s idle inside a transaction, the backend is terminated and the client sees FATAL: terminating connection due to idle-in-transaction timeout. Loud is correct: the alternative is a lock queue nobody can see. Set it per role for batch jobs that legitimately pause (ALTER ROLE reporter SET idle_in_transaction_session_timeout = '30min'). Postgres 14 added idle_session_timeout for connections that are idle outside a transaction, which is for sessions that forgot to disconnect; leave it at 0 when a pooler holds warm connections, or set it longer than PgBouncer’s server_idle_timeout (default 600 s), or the two will fight.

The query you will run more than any other in this area:

SELECT state, wait_event_type, count(*), max(now() - state_change) AS longest
FROM pg_stat_activity
WHERE backend_type = 'client backend'
GROUP BY 1, 2 ORDER BY 3 DESC;

If idle dominates, the pools are too big. If idle in transaction appears with a longest over a few seconds, something is holding a transaction open and the timeout above is your fix. If active is far above the core count, you have the collapse from the first half of this chapter and the pooler is your fix.

LAB Collapse under 1000 connections, recover through PgBouncer, break transaction mode ~45 MIN
YOU NEEDDocker Compose with labs/databases started using the pool profile: docker compose --profile pool up -d (Postgres 17 on 5432, PgBouncer 1.24.1 on 6432 in transaction mode, atlas listed in admin_users, max_client_conn 1200)the shop loaded at scale=1 (or 0.1 on a small laptop); the lab reads orders by primary keya machine with at least 4 cores and 8 GB of RAM; note your core count, the curves are relative to it

You will run the same point-read workload at 50, 200 and 1000 clients, first against Postgres directly and then through PgBouncer in transaction mode, record throughput and p99, and watch the collapse and the recovery. Then you will break transaction mode with a prepared statement and fix it with one setting. All commands run from labs/databases. pgbench runs inside the db container so it can reach both Postgres and PgBouncer by service name. The compose file’s one-shot pgbench service (docker compose --profile bench run --rm pgbench ...) reaches them the same way, but this lab needs a shell around pgbench to collect its per-transaction logs, which the db container has.

1. Write the workload and measure the cost of connecting.

docker compose exec db sh -c 'cat > /tmp/point.sql <<EOF
\set id random(1, 2000000)
SELECT id, status, total_cents FROM orders WHERE id = :id;
EOF'
docker compose exec -e PGPASSWORD=atlas db pgbench -h localhost -U atlas -n -f /tmp/point.sql -c 10 -j 2 -T 10 shop
docker compose exec -e PGPASSWORD=atlas db pgbench -h localhost -U atlas -n -f /tmp/point.sql -c 10 -j 2 -T 10 -C shop
The first run reports a few thousand to tens of thousands of TPS and a latency average under 1 ms: ten persistent connections doing primary-key lookups. The second, with -C (a new connection per transaction), reports a few hundred TPS and a latency average of several milliseconds. The difference is the fork, the SCRAM handshake and the cold catalogue cache, paid 10 times per millisecond instead of once. If you use scale 0.1, change the random upper bound to 200000 so the ids exist.

2. Collapse: direct connections at 50, 200 and 1000.

Postgres ships with max_connections = 100, so first raise it and restart (it needs a restart; shared memory is sized from it):

docker compose exec db psql -U atlas shop -c "ALTER SYSTEM SET max_connections = 2000;"
docker compose restart db && sleep 5
docker compose exec db psql -U atlas shop -c "SHOW max_connections;"

Now run the three sizes. The -l flag writes one line per transaction with its duration in microseconds (field 3); the awk pipeline turns that into a p99.

docker compose exec db sh -c 'nproc; for c in 50 200 1000; do
  rm -f /tmp/pgbench_log.*
  PGPASSWORD=atlas pgbench -h localhost -U atlas -n -f /tmp/point.sql -c $c -j 8 -T 20 -l --log-prefix=/tmp/pgbench_log shop 2>/dev/null | grep -E "^tps|latency average"
  cat /tmp/pgbench_log.* | awk "{print \$3}" | sort -n | awk "{a[NR]=\$1} END {printf \"p99 = %.1f ms  (n=%d)\n\n\", a[int(NR*0.99)]/1000, NR}"
done'
On an 8-core laptop, something like: -c 50 25,000 TPS, latency average 2 ms, p99 5 ms. -c 200 about the same TPS or a little less, latency average 8 ms, p99 25 ms: the same work, queued four times deeper. -c 1000 TPS drops by a third to a half, latency average 40 to 80 ms, p99 150 ms or more, and the run takes a noticeable moment to start while 1000 backends fork. Record all six numbers. The exact values depend on your cores and on Docker’s overhead; the shape is what matters: flat throughput then a fall, with p99 climbing an order of magnitude at each step. While the 1000-client run is going, docker stats db in another terminal shows CPU far above what 50 clients needed for the same TPS.

3. Recover: the same three sizes through PgBouncer in transaction mode.

The compose file already starts PgBouncer in transaction mode (POOL_MODE: transaction) with a pool of 20 server connections per database and user. Open the admin console, set the pool close to your core count, and check the pool is empty:

docker compose exec -e PGPASSWORD=atlas db psql -h pgbouncer -p 6432 -U atlas pgbouncer \
  -c "SET default_pool_size = 16;" -c "SHOW POOLS;"

Then the same loop against port 6432 on host pgbouncer:

docker compose exec db sh -c 'for c in 50 200 1000; do
  rm -f /tmp/pgbench_log.*
  PGPASSWORD=atlas pgbench -h pgbouncer -p 6432 -U atlas -n -f /tmp/point.sql -c $c -j 8 -T 20 -l --log-prefix=/tmp/pgbench_log shop 2>/dev/null | grep -E "^tps|latency average"
  cat /tmp/pgbench_log.* | awk "{print \$3}" | sort -n | awk "{a[NR]=\$1} END {printf \"p99 = %.1f ms  (n=%d)\n\n\", a[int(NR*0.99)]/1000, NR}"
done'

During the 1000-client run, in a second terminal:

docker compose exec -e PGPASSWORD=atlas db psql -h pgbouncer -p 6432 -U atlas pgbouncer -c "SHOW POOLS;"
docker compose exec db psql -U atlas shop -c "SELECT state, count(*) FROM pg_stat_activity WHERE datname = 'shop' GROUP BY 1;"
TPS is roughly the same at all three client counts, and close to the direct -c 50 figure, perhaps 10 to 20 percent lower because every query now crosses PgBouncer’s single thread. p99 still grows with client count (1000 clients sharing 16 backends must queue), but it grows less than it did directly and the 1000-client run no longer collapses. SHOW POOLS shows cl_active near 1000, sv_active at 16, and cl_waiting in the hundreds: the queue is now in PgBouncer, at a few kilobytes per waiter, instead of in 1000 forked backends. pg_stat_activity shows 16 or 17 backends for shop instead of 1000. Put the six pairs from steps 2 and 3 side by side: that is the collapse and the recovery.

4. Break transaction mode with a prepared statement.

PgBouncer 1.24 ships with max_prepared_statements = 200, so first put it back to the world before 1.21, then run pgbench with protocol-level prepared statements (-M prepared; pgbench names them P_0, P_1, …):

docker compose exec -e PGPASSWORD=atlas db psql -h pgbouncer -p 6432 -U atlas pgbouncer -c "SET max_prepared_statements = 0;"
docker compose exec -e PGPASSWORD=atlas db pgbench -h pgbouncer -p 6432 -U atlas -n -f /tmp/point.sql -M prepared -c 50 -j 4 -T 10 shop 2>&1 | head -5
Within the first second: pgbench: error: client N script 0 aborted in command 1 query 0: ERROR: prepared statement “P_0” does not exist, repeated for most clients, and the run ends early with a fraction of the transactions. Each client prepared P_0 on the server connection it held for its first transaction. Its second transaction landed on a different server connection where P_0 was never parsed. This is the error every team that moved an ORM behind PgBouncer saw between 2010 and 2023.

Now fix it with the setting, and prove it worked:

docker compose exec -e PGPASSWORD=atlas db psql -h pgbouncer -p 6432 -U atlas pgbouncer -c "SET max_prepared_statements = 200;"
docker compose exec -e PGPASSWORD=atlas db pgbench -h pgbouncer -p 6432 -U atlas -n -f /tmp/point.sql -M prepared -c 50 -j 4 -T 10 shop 2>&1 | grep -E "^tps|aborted"
docker compose exec -e PGPASSWORD=atlas db psql -h pgbouncer -p 6432 -U atlas pgbouncer -c "SHOW STATS;" | head -3
No aborted lines, a TPS figure a little higher than the unprepared run (the server skips parsing from the second execution on), and SHOW STATS with non-zero prepared-statement counters for shop. PgBouncer now holds a per-client table of named statements and re-sends the Parse on whichever server connection the transaction lands on.
Switch the pool back to SET pool_mode = ‘session’; on the console and re-run the -c 200 step through PgBouncer. The first 16 clients get a server connection each and keep it for the whole run; the other 184 wait in cl_waiting for a server that is never released, until query_wait_timeout (120 s) disconnects them with query_wait_timeout errors, or the 20 s run ends first and they report zero transactions. Session mode caps backends, and it does not multiplex: the queue is the whole story. Then set ALTER SYSTEM SET idle_in_transaction_session_timeout = ‘5s’; SELECT pg_reload_conf();, open psql through port 6432 in transaction mode, run BEGIN; SELECT 1; and wait six seconds before the next statement: FATAL: terminating connection due to idle-in-transaction timeout. Your psql held one of the 16 server connections the whole time it was idle, which is why the timeout exists. Set everything back when you are done: SET pool_mode = ‘transaction’; on the console, then ALTER SYSTEM RESET idle_in_transaction_session_timeout; ALTER SYSTEM RESET max_connections; in psql and docker compose restart db, so the next chapter starts from the default 100 connections.
DECIDE

A Node service runs 40 pods, each with a node-postgres Pool of max 10, against a managed Postgres with 4 vCPUs and max_connections = 500. At peak, p99 for a 1 ms primary-key lookup is 60 ms and the database CPU is pinned. pg_stat_activity shows about 380 connections, 300 of them idle. The team uses SET LOCAL for a per-tenant search_path and protocol-level prepared statements through the driver. What do you change first?

READING
  1. DOC
    PgBouncer features: pool modes and the feature matrix

    The table of what works in session, transaction and statement pooling. Read the 'Never' column for transaction mode before you move an application behind it; the rest of the page is a two-minute skim.

  2. DOC
    PgBouncer configuration

    Every knob named in this chapter: pool_mode, default_pool_size, max_client_conn, server_reset_query, max_prepared_statements, query_wait_timeout, track_extra_parameters. Read the Pool configuration and Timeouts sections; skip the TLS and HBA sections until you need them.

  3. POST
    How to Manage Connections Efficiently in Postgres, or Any Database Brandur Leach, 2018

    The process model, the per-backend memory, the three PgBouncer modes and the minimum-viable-checkout idea in one readable post from someone who ran this at Heroku and Stripe. The benchmark at the end is informal; use Freund's for numbers.

  4. POST
    Analyzing the Limits of Connection Scalability in Postgres Andres Freund, 2020

    The measurements behind this chapter's table: 48 active clients against 0 to 10,000 idle connections, the CPU profile that pins the cost on GetSnapshotData(), and the memory measurements that show per-backend RAM is not the main problem. Read the snapshot section closely; the memory section is optional.

  5. POST
    Improving Postgres Connection Scalability: Snapshots Andres Freund, 2020

    The follow-up: what changed in Postgres 14's snapshot code and the same benchmark re-run. Read it to know how much of the idle-connection penalty your Postgres version still pays.

  6. DOC
    Number Of Database Connections

    The origin of the cores x 2 + spindles formula, with the reasoning about context switches, lock contention and cache lines. Short; read all of it and note its own caveat about SSDs.

  7. DOC
    About Pool Sizing

    HikariCP's restatement of the formula with the Oracle 2048-to-96 demonstration and the two caveats that matter in practice: mixed workloads and the pool-locking deadlock formula. Ten minutes.

  8. DOC
    Postgres 17: Client Connection Defaults (statement behaviour)

    The reference text for idle_in_transaction_session_timeout, idle_session_timeout, lock_timeout and statement_timeout, with defaults and units. Read those four entries; the rest of the page is locale and formatting settings.

All companies and people in these examples are fictional. Any resemblance to a real business or person is unintended.

RECALL CARDS Tap to flip. They join your review deck when you mark the lesson complete.
NEXT: Project: diagnose five slow queries under load →