1 GB server test · protocol v2 · Ubuntu 24.04.5 LTS on a $6 droplet (1 vCPU / 1 GB)
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.
jsonable_encoder, asyncpg), Postgres ≈ 0.85–0.9 ms.conn p95 399 ms at 600 VUs and 1110 ms at 650; db p95 stays 21–29 ms at every level; app p95 ≈ 2 ms. 0 % errors at every level.python-fastapi-v03-feed-cache-1s (user's choice) — the 1 s in-process cache of GET /posts with single-flight, ported from node-http. On Node it took capacity from 1400 to 3000 VUs; with Python's app CPU the dominant cost, skipping DB access and JSON encoding for ≈ 47 % of requests should matter even more.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.
| VUs | Result | req/s | p50 | p95 | p99 | Errors % | Server | Conn | CPU % (Node / PG) | Used MB | Load gen CPU % |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 400 | Pass | 211.9 | 18 | 199 | 384 | 0.00 | 14 / 176 | 7 / 154 | 84 (56 / 22) | 455 | 43 |
| 450 | Pass | 239.8 | 16 | 104 | 246 | 0.00 | 12 / 83 | 6 / 61 | 84 (57 / 23) | 459 | 19 |
| 500 | Pass | 266.1 | 20 | 114 | 194 | 0.00 | 15 / 95 | 8 / 77 | 87 (58 / 23) | 462 | 28 |
| 600 | Pass | 306.9 | 43 | 435 | 863 | 0.00 | 33 / 415 | 20 / 399 | 94 (64 / 26) | 463 | 60 |
| 650 | Failp95 1153>=800ms, p99 2016>=1000ms | 297.8 | 169 | 1,153 | 2,016 | 0.00 | 154 / 1,130 | 140 / 1,110 | 99 (67 / 27) | 469 | 38 |
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.
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.
apps/python-fastapi — FastAPI 0.143.0 (Starlette 1.7.0, Pydantic 2.14.1), asyncpg 0.32.0, plain SQL, no ORM; dependencies pinned in requirements.txt (app code from commit 57434bf)--no-access-logbench-app)Server-Timing: conn, db, app, total on every response (conn = acquire + release)shared_buffers=128MB, max_connections=100), localhost TCP, SCRAM authdo-blr1-loadgen-4vcpu-8gb), k6 v2.3.0, traffic to the target's private IP 10.122.0.2app p95 stays ≈ 2 ms at every level: per-request Python work is small, but ≈ 2.2 ms of CPU per request across the event loop, HTTP parsing and the framework is what saturates the vCPU at ≈ 300 req/s.app_log_tail.txt has no errors at any level.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.