The 1 GB Server Test measures how much traffic a 1 vCPU, 1 GB DigitalOcean droplet can serve with Postgres on the same box, changing one thing per run. The very first change, adding a connection pool, was the biggest win of the whole project, so it is worth understanding why.
Where the time went without a pool
The baseline Express app opened a fresh Postgres connection for every request and closed it afterwards. Each response carried a Server-Timing header, which split the server's time into parts.
- Connect and authenticate181 ms
- Database queries38 ms
- App code0.5 ms
Opening a Postgres connection is real work. There is a TCP handshake, Postgres starts a new backend process for the session, and SCRAM authentication runs a deliberately slow password hash. On a machine with one CPU, all of that competes with the queries themselves. The baseline was CPU-bound, at 98%.
What a pool changes
No pool
Request
Connect + auth
every time
Query
Close
Pool of 10
Request
Borrow a connection
or wait for one
Query
Return it
stays open
Switching to pg.Pool with its defaults (at most 10 connections) took capacity from 100 to 1,350 concurrent users, and throughput from 46.7 to 619 requests per second.
Why 20 connections lost to 10
- Express, no pool100 users
- Express, pool of 101,350 users
- Express, pool of 201,200 users
- FastAPI, no pool60 users
- FastAPI, pool of 10600 users
It is tempting to think more connections means more work done at once. But one vCPU can only do one query's work at a time. Doubling the pool doubled how many queries were fighting for that CPU, and query time at p95 roughly doubled too, from 37–48 ms to 83–102 ms.
With 10 connections, the overload looked different. Past the limit, the queries themselves stayed fast (p95 at most 48 ms) and the extra latency was requests waiting for a free connection. That is the pool doing its job: it is a queue in front of the database, and a short queue is better than an overloaded CPU.
What I took from it
- Measure where the time goes before tuning anything. The fix was obvious once Server-Timing showed 181 of 227 ms in connection setup.
- Size a pool to what the database machine can actually run in parallel, not to the number of users.
- The same lesson held in Python: an asyncpg pool took FastAPI from 60 to 600 users. There, Python's own CPU work became the next ceiling.
Where it went from here
The pool was step one. A 1-second feed cache, plain node:http and then Bun took the same box to 4,500 users. The full path is in the project write-up.