1 GB server test · protocol v2 · Ubuntu 24.04.5 LTS on a $6 droplet (1 vCPU / 1 GB)

python-fastapi-v02-pool

FastAPI 0.143.0 + uvicorn 0.54.0 (asyncio loop, h11) · asyncpg 0.32.0 · pool: asyncpg pool min 10 / max 10 · Node v24.21.0 · Postgres 16.15 · load from do-blr1-loadgen-4vcpu-8gb · app dd04bd0

Capacity600 VUs 306.9 req/s steady
First failing level650 VUs
Highest throughput seen306.9 req/s
Pass rulep50 < 500 · p95 < 800 · p99 < 1000 ms
errors < 1 %
Steady throughput306.9req/s · 18,417 req/min
Client p95 / p99435 / 863ms, steady phase
Server time p5032.6ms inside the app
Spent getting a connection60 %of server p50 (19.7 ms)
CPU (1 vCPU)94 %Node 64 · Postgres 26
Memory used463 MBof 961 MB · Node 71 · PG 112

Summary

Capacity: 600 VUs at 306.9 req/s (18,414 req/min), steady p50 43 ms / p95 435 ms / p99 863 ms, 0 % errors (p99 14 % under its limit). The first failing level is 650 VUs: 297.8 req/s, p95 1153 ms / p99 2016 ms, still 0 % errors, on a normal-speed host (probe 85 ms). 10× the VUs of v01 (60 VUs / 29.9 req/s) from one change, the pool. node-express v02 (the same step on Node + Express) reached 1350 VUs / 619 req/s: Python with a pool is at ≈ 45 % of Node's capacity.

Levels tested

Latency is the client-observed steady phase (60 s hold). Red values miss the pass rule. Server and conn come from the app's Server-Timing header, p50 / p95 in ms.

VUsResultreq/sp50p95p99Errors %ServerConnCPU % (Node / PG)Used MBLoad gen CPU %
400Pass211.9181993840.0014 / 1767 / 15484 (56 / 22)45543
450Pass239.8161042460.0012 / 836 / 6184 (57 / 23)45919
500Pass266.1201141940.0015 / 958 / 7787 (58 / 23)46228
600Pass306.9434358630.0033 / 41520 / 39994 (64 / 26)46360
650Failp95 1153>=800ms, p99 2016>=1000ms297.81691,1532,0160.00154 / 1,130140 / 1,11099 (67 / 27)46938

Across levels

Client latency vs. users steady phase, ms; dashed = limits
Where server time goes p50 per request, ms

During the run

From k6's 2-second snapshots and the 1-second server samples, aligned on the k6 start. The shaded band is the 60 s ramp; the hold phase follows.

Load active users, req/s, failed req/s
Latency over time 2 s windows, ms
Target droplet CPU % of 1 vCPU, memory used MB
p95 by endpoint client vs. server, ms, whole run

What changed vs. the previous tag

Parent: python-fastapi-v01-baseline. One change: a connection pool — asyncpg.create_pool(min_size=10, max_size=10) created at startup (FastAPI lifespan), instead of a new connection per request. Every request acquires one connection for all its queries and releases it before the response is sent. asyncpg's pool defaults otherwise: on release it runs the reset query (SELECT pg_advisory_unlock_all(); CLOSE ALL; UNLISTEN *; RESET ALL;, one round trip), and prepared statements are cached per connection (100 statements). conn now measures pool acquire (waiting for a free connection) plus release. The 10 connections are opened at startup (asyncpg's default min_size=10); the Node pools opened them on demand. The parity check gave responses identical to the node-http reference. App code from commit 57434bf.

Full configuration

Observations

Next idea

python-fastapi-v03-feed-cache-1s (parent v02): in-process cache of GET /posts (all pages, key limit + before, TTL 1 s, single-flight, cached as the encoded JSON body), the only change — the same cache as node-express v06 / node-http. Then uvloop + httptools, orjson, more workers.