Sizing a Payment Gateway for Peak Traffic

Back-of-envelope math for throughput, connection pools, and the assumptions that broke during Black Friday.

Before writing a line of code for the gateway rewrite, I documented expected load and failure modes. This note captures the model we used — and where it was wrong.

Assumptions

ParameterEstimateSource
Peak RPS12,000Last Black Friday + 30% buffer
P99 latency target150msProduct SLA
Avg payload2.4 KBAccess logs sample
DB writes per request0.3Mostly reads, audit on mutations

The Model

Required app instances = Peak RPS / (RPS per pod at P99 target)
RPS per pod ≈ 500 (measured under load test with 150ms P99)
Instances = 12,000 / 500 = 24 pods (+ 20% headroom) → 30 pods

Connection math mattered more than CPU:

  • 30 pods × 20 DB connections = 600 client connections
  • PgBouncer pool capped at 100 → bottleneck identified before prod

What We Got Wrong

Load tests used uniform traffic. Real Black Friday traffic spiked in 90-second bursts — 3× average for short windows. HPA lagged by 45 seconds. Fix: custom metrics on request rate, not CPU.

capacity-planning , gateway , trade-offs · Kubernetes , PostgreSQL , Redis

More in System Design