14 lines
2.0 KiB
Plaintext
14 lines
2.0 KiB
Plaintext
Track 1 — cost of scaling
|
||
hypothesis: With a fixed total API CPU/RAM budget (2.0 CPU / 512M), two replicas outperform both one (a single uvicorn worker cannot spend 2.0 CPU) and four (each worker is capped at 0.5 CPU, p95 collapses). Growing per-replica CPU still raises RPS until that slice is no longer tiny. PostgreSQL and HAProxy stay below their limits; extra replicas past 2 only add pool connections to the same 1.0-CPU database. The confirmed improvement is 2×1.0 instead of 4×0.5 at the same budget.
|
||
profile: {"concurrency": 24, "warmup_seconds": 5, "measure_seconds": 20, "workload": "closed-loop POST /api/v1/chats/{id}/messages through HAProxy", "fixed_budget": "API total 2.0 CPU / 512M; postgres 1.0 CPU / 512M; pool 10 per replica"}
|
||
|
||
id series N api_cpu api_mem pg_cpu rps p95 err api_u%% pg_u%% lb_u%% pool%% backends sat
|
||
fixed-1 fixed 1 2.0 512M 1.0 187.5 203.6 0 49.3 46.8 39.8 110.0 11.0 pool
|
||
fixed-2 fixed 2 1.0 256M 1.0 249.5 196.7 0 85.1 66.2 46.6 105.0 21.0 pool
|
||
fixed-4 fixed 4 0.5 128M 1.0 185.8 464.5 0 82.8 61.7 37.6 98.5 39.38 pool
|
||
grow-0.25 grow 2 0.25 256M 1.0 25.1 1916.3 0 96.0 26.4 11.6 105.0 21.0 pool
|
||
grow-0.50 grow 2 0.50 256M 1.0 93.8 593.2 0 97.3 37.6 24.1 105.0 21.0 pool
|
||
improve-pool20 improve 2 1.0 256M 1.0 140.7 396.9 0 89.2 63.3 45.2 87.8 35.14 api
|
||
|
||
finding: Fixed 2.0 CPU / 512M budget: 1/2/4 replicas → 187.5 / 249.5 / 185.8 RPS. One replica uses only 49% of a 2.0 limit (single uvicorn worker ≈ 1 core). Four replicas cap each worker at 0.5 CPU (p95 464.5 ms). Growing 2×CPU 0.25→0.50→1.0: 25.1 → 93.8 → 249.5 RPS; API util 96%/97% then 85%; postgres util 66%; LB util 47%. Confirmed improvement: same budget, 4×0.5 → 2×1.0 raises RPS 185.8 → 249.5 (+34.2%) and p95 464.5 → 196.7 ms. Raising DB_POOL_MAX 10→20 was tried and rejected (140.7 RPS, p95 396.9 ms).
|