Performance
Last updated: 2026-11-15T20:02:50-03:00 (UTC-3)
This gateway’s own numbers, measured on one machine against a simulated upstream, with the upstream called directly as the baseline. This page is generated from results.json by scripts/render-performance.py; how the numbers are taken is in How performance is measured, and a load test of the JSON and streaming paths is in Local load test.
Highlights
Section titled “Highlights”| Metric | ai-gateway |
|---|---|
| Overhead per request (p50, c=1, production mode) | +2.5 ms |
| Throughput with an instant upstream (c=32, production mode) | 2,300 req/s |
| CPU per request (c=1, production mode) | 0.37 ms |
| Peak memory (c=1, production mode) | 28 MB |
Measured at commit cf83f6fb. Environment: Mac Mini M4 Pro (Apple Silicon, 12 cores); Docker Desktop for the 2026-10-26 rounds, OrbStack 2.2.5 (Docker 29.8.2) for the 2026-11-14 rounds; the gateway in a container with –cpus 2, upstream simulated by gwbench -mock on the same host.
Cost per request: concurrency 1, instant upstream, minimal mode
Section titled “Cost per request: concurrency 1, instant upstream, minimal mode”With no queue, the difference from direct is the gateway’s work on each call.
| Target | overhead p50 | p99 | CPU ms/req | peak memory |
|---|---|---|---|---|
| ai-gateway | +0.1 ms | 3.5 ms | 0.09 | 21 MB |
Measured on 2026-10-26; source: fair round of 2026-10-26 (gwbench Markdown output, transcribed when this page was created), commit 54414f9.
Under load: instant upstream, minimal mode
Section titled “Under load: instant upstream, minimal mode”| Target | c=32 p50 | c=32 req/s | c=128 p50 | CPU ms/req |
|---|---|---|---|---|
| ai-gateway | 2.0 ms | 13,190 | 6.6 ms | 0.09–0.11 |
Measured on 2026-10-26; source: fair round of 2026-10-26 (gwbench Markdown output, transcribed when this page was created), commit 54414f9.
Realistic upstream, stream, minimal mode
Section titled “Realistic upstream, stream, minimal mode”A TTFT of 300 ms and a token every 20 ms: the scenario of a real provider.
| Target | c=8 TTFT p50 | c=128 p50 | c=512 p50 | c=512 req/s | c=512 CPU ms/req | c=512 mem |
|---|---|---|---|---|---|---|
| direct | 306.1 ms | 669.5 ms | 644.5 ms | 486 | — | — |
| ai-gateway | 307.9 ms (+1.8) | 658.1 ms | 638.6 ms | 727 | 0.35 | 97 MB |
Measured on 2026-10-26; source: fair round of 2026-10-26 (gwbench Markdown output, transcribed when this page was created), commit 54414f9.
Production mode: persistence per request
Section titled “Production mode: persistence per request”The gateway writes the durable receipt before inference (durable_usage), plus analytics, logs and timing, to PostgreSQL.
| Target | c=1 p50 | c=32 p50 | c=128 req/s | realistic c=512 p50 | CPU ms/req |
|---|---|---|---|---|---|
| ai-gateway (PostgreSQL) | 3.6 ms | 13.8 ms | 2,240 | 684 ms (558 req/s) | 0.29–0.73 |
Measured on 2026-10-26; source: fair round of 2026-10-26 (gwbench Markdown output, transcribed when this page was created), commit 54414f9.
Production mode, cost per request: concurrency 1, instant upstream
Section titled “Production mode, cost per request: concurrency 1, instant upstream”PostgreSQL per request; the 2026-10-26 baseline commit, the tip before T159 and T159 at gc_percent 200 (default) and 100 in the same alternating rounds (T159).
| Target | p50 | p99 | overhead p50 | req/s | TTFT p50 | CPU ms/req | peak mem | errors |
|---|---|---|---|---|---|---|---|---|
| direct (c=1) | 0.1 ms | 0.3 ms | — | 7,902 | — | — | — | 0.0% |
| ai-gateway-54414f9 (c=1) | 2.5 ms | 8.6 ms | +2.4 ms | 285 | — | 0.44 | 14 MB | 0.0% |
| ai-gateway-c6a6ea8f (c=1) | 2.5 ms | 8.1 ms | +2.4 ms | 290 | — | 0.40 | 40 MB | 0.0% |
| ai-gateway (c=1) | 2.6 ms | 7.8 ms | +2.5 ms | 296 | — | 0.37 | 28 MB | 0.0% |
| ai-gateway-gogc100 (c=1) | 5.4 ms | 9.3 ms | +5.3 ms | 207 | — | 0.55 | 26 MB | 0.0% |
Measured on 2026-11-15 at commit cf83f6fb; source: gwbench, the last of five alternating repetitions of the T159 re-measurement (spread over all five in How performance is measured); ai-gateway is commit cf83f6fb (T159) at its default gc_percent 200, ai-gateway-gogc100 the same binary with GOGC=100, ai-gateway-c6a6ea8f the tip before T159 and ai-gateway-54414f9 the 2026-10-26 baseline, all with the same configuration.
Production mode under load: instant upstream
Section titled “Production mode under load: instant upstream”PostgreSQL per request, default pool of 10 connections; same rounds as above (T159).
| Target | p50 | p99 | overhead p50 | req/s | TTFT p50 | CPU ms/req | peak mem | errors |
|---|---|---|---|---|---|---|---|---|
| direct (c=32) | 0.6 ms | 8.1 ms | — | 18,375 | — | — | — | 0.0% |
| ai-gateway-54414f9 (c=32) | 13.5 ms | 66.3 ms | +12.9 ms | 1,617 | — | 0.32 | 19 MB | 0.0% |
| ai-gateway-c6a6ea8f (c=32) | 13.5 ms | 50.2 ms | +12.9 ms | 1,653 | — | 0.28 | 50 MB | 0.0% |
| ai-gateway (c=32) | 13.0 ms | 35.3 ms | +12.4 ms | 2,300 | — | 0.26 | 25 MB | 0.0% |
| ai-gateway-gogc100 (c=32) | 13.6 ms | 46.5 ms | +13.0 ms | 1,878 | — | 0.28 | 20 MB | 0.0% |
| direct (c=128) | 0.6 ms | 202.5 ms | — | 8,951 | — | — | — | 0.0% |
| ai-gateway-54414f9 (c=128) | 53.9 ms | 359.0 ms | +53.2 ms | 1,557 | — | 0.33 | 32 MB | 0.0% |
| ai-gateway-c6a6ea8f (c=128) | 51.9 ms | 93.0 ms | +51.3 ms | 2,406 | — | 0.26 | 64 MB | 0.0% |
| ai-gateway (c=128) | 53.6 ms | 383.8 ms | +53.0 ms | 1,598 | — | 0.28 | 41 MB | 0.0% |
| ai-gateway-gogc100 (c=128) | 54.3 ms | 390.3 ms | +53.6 ms | 1,590 | — | 0.29 | 32 MB | 0.0% |
Measured on 2026-11-15 at commit cf83f6fb; source: gwbench, the last of five alternating repetitions of the T159 re-measurement (spread over all five in How performance is measured); ai-gateway is commit cf83f6fb (T159) at its default gc_percent 200, ai-gateway-gogc100 the same binary with GOGC=100, ai-gateway-c6a6ea8f the tip before T159 and ai-gateway-54414f9 the 2026-10-26 baseline, all with the same configuration.
Production mode, realistic upstream, stream
Section titled “Production mode, realistic upstream, stream”TTFT 300 ms and a token every 20 ms, PostgreSQL per request; same rounds as above (T159).
| Target | p50 | p99 | overhead p50 | req/s | TTFT p50 | CPU ms/req | peak mem | errors |
|---|---|---|---|---|---|---|---|---|
| direct (c=32) | 669.9 ms | 880.6 ms | — | 46 | 310.0 ms | — | — | 0.0% |
| ai-gateway-54414f9 (c=32) | 696.4 ms | 735.6 ms | +26.5 ms | 44 | 322.4 ms | 2.54 | 24 MB | 0.0% |
| ai-gateway-c6a6ea8f (c=32) | 683.6 ms | 894.0 ms | +13.7 ms | 44 | 319.3 ms | 2.79 | 54 MB | 0.0% |
| ai-gateway (c=32) | 693.6 ms | 740.3 ms | +23.8 ms | 44 | 322.2 ms | 2.74 | 32 MB | 0.0% |
| ai-gateway-gogc100 (c=32) | 701.6 ms | 740.7 ms | +31.7 ms | 44 | 322.9 ms | 2.75 | 26 MB | 0.0% |
Measured on 2026-11-15 at commit cf83f6fb; source: gwbench, the last of five alternating repetitions of the T159 re-measurement (spread over all five in How performance is measured); ai-gateway is commit cf83f6fb (T159) at its default gc_percent 200, ai-gateway-gogc100 the same binary with GOGC=100, ai-gateway-c6a6ea8f the tip before T159 and ai-gateway-54414f9 the 2026-10-26 baseline, all with the same configuration.
Translated cells, cost per request: concurrency 1, instant upstream
Section titled “Translated cells, cost per request: concurrency 1, instant upstream”Every client route against every upstream dialect of the mock, PostgreSQL per request; the 2026-10-26 baseline commit serves only the same-protocol cells (T077.001).
| Target | p50 | p99 | overhead p50 | req/s | TTFT p50 | CPU ms/req | peak mem | errors |
|---|---|---|---|---|---|---|---|---|
| direct messages (c=1) | 0.1 ms | 0.2 ms | — | 9,312 | — | — | — | 0.0% |
| ai-gateway chat→openai-chat (c=1) | 1.7 ms | 8.8 ms | +1.6 ms | 400 | — | 0.28 | 57 MB | 0.0% |
| ai-gateway-54414f9 chat→openai-chat (c=1) | 2.8 ms | 9.7 ms | +2.7 ms | 269 | — | 0.42 | 20 MB | 0.0% |
| ai-gateway chat→openai-responses (c=1) | 5.8 ms | 11.2 ms | +5.7 ms | 182 | — | 0.68 | 57 MB | 0.0% |
| ai-gateway chat→anthropic (c=1) | 6.2 ms | 11.9 ms | +6.1 ms | 154 | — | 0.80 | 56 MB | 0.0% |
| ai-gateway chat→gemini (c=1) | 6.2 ms | 11.0 ms | +6.1 ms | 154 | — | 0.84 | 56 MB | 0.0% |
| ai-gateway responses→openai-responses (c=1) | 5.6 ms | 28.8 ms | +5.5 ms | 129 | — | 0.72 | 56 MB | 0.0% |
| ai-gateway-54414f9 responses→openai-responses (c=1) | 5.7 ms | 10.0 ms | +5.6 ms | 174 | — | 0.73 | 21 MB | 0.0% |
| ai-gateway responses→openai-chat (c=1) | 5.5 ms | 10.2 ms | +5.4 ms | 193 | — | 0.68 | 56 MB | 0.0% |
| ai-gateway responses→anthropic (c=1) | 5.6 ms | 23.5 ms | +5.5 ms | 171 | — | 0.70 | 57 MB | 0.0% |
| ai-gateway responses→gemini (c=1) | 3.2 ms | 8.0 ms | +3.1 ms | 252 | — | 0.46 | 57 MB | 0.0% |
| ai-gateway messages→anthropic (c=1) | 5.5 ms | 10.3 ms | +5.4 ms | 183 | — | 0.63 | 57 MB | 0.0% |
| ai-gateway-54414f9 messages→anthropic (c=1) | 5.0 ms | 9.2 ms | +4.9 ms | 212 | — | 0.53 | 20 MB | 0.0% |
| ai-gateway messages→openai-chat (c=1) | 2.5 ms | 7.6 ms | +2.4 ms | 324 | — | 0.37 | 56 MB | 0.0% |
| ai-gateway messages→openai-responses (c=1) | 2.5 ms | 4.7 ms | +2.4 ms | 371 | — | 0.27 | 56 MB | 0.0% |
| ai-gateway messages→gemini (c=1) | 2.6 ms | 8.5 ms | +2.5 ms | 264 | — | 0.45 | 56 MB | 0.0% |
| direct chat (c=1) | 0.1 ms | 0.3 ms | — | 8,057 | — | — | — | 0.0% |
| direct responses (c=1) | 0.1 ms | 0.2 ms | — | 9,162 | — | — | — | 0.0% |
Measured on 2026-11-15 at commit 2a091a57; source: gwbench, the last of four alternating repetitions of T077.001 (spread over all four in How performance is measured); ai-gateway is commit 2a091a57 and ai-gateway-54414f9 the 2026-10-26 baseline, which serves only the same-protocol cells; each overhead is against the direct target of the same client dialect.
Translated cells under load: concurrency 32, instant upstream
Section titled “Translated cells under load: concurrency 32, instant upstream”Same cells and rounds as above, default pool of 10 PostgreSQL connections (T077.001).
| Target | p50 | p99 | overhead p50 | req/s | TTFT p50 | CPU ms/req | peak mem | errors |
|---|---|---|---|---|---|---|---|---|
| direct messages (c=32) | 0.7 ms | 9.0 ms | — | 19,825 | — | — | — | 0.0% |
| ai-gateway chat→openai-chat (c=32) | 14.9 ms | 92.4 ms | +14.4 ms | 1,229 | — | 0.32 | 59 MB | 0.0% |
| ai-gateway-54414f9 chat→openai-chat (c=32) | 15.1 ms | 231.0 ms | +14.6 ms | 810 | — | 0.44 | 24 MB | 0.0% |
| ai-gateway chat→openai-responses (c=32) | 14.6 ms | 192.4 ms | +14.1 ms | 1,491 | — | 0.32 | 59 MB | 0.0% |
| ai-gateway chat→anthropic (c=32) | 14.5 ms | 47.3 ms | +14.0 ms | 2,020 | — | 0.26 | 59 MB | 0.0% |
| ai-gateway chat→gemini (c=32) | 13.8 ms | 20.1 ms | +13.2 ms | 2,162 | — | 0.26 | 59 MB | 0.0% |
| ai-gateway responses→openai-responses (c=32) | 13.6 ms | 225.8 ms | +12.8 ms | 1,258 | — | 0.29 | 59 MB | 0.2% |
| ai-gateway-54414f9 responses→openai-responses (c=32) | 13.8 ms | 22.1 ms | +13.0 ms | 2,246 | — | 0.29 | 24 MB | 0.0% |
| ai-gateway responses→openai-chat (c=32) | 14.2 ms | 22.7 ms | +13.3 ms | 2,186 | — | 0.27 | 59 MB | 0.0% |
| ai-gateway responses→anthropic (c=32) | 14.3 ms | 21.7 ms | +13.5 ms | 2,171 | — | 0.28 | 59 MB | 0.0% |
| ai-gateway responses→gemini (c=32) | 14.7 ms | 100.2 ms | +13.9 ms | 1,719 | — | 0.30 | 59 MB | 0.0% |
| ai-gateway messages→anthropic (c=32) | 15.1 ms | 224.5 ms | +14.4 ms | 1,068 | — | 0.35 | 59 MB | 0.0% |
| ai-gateway-54414f9 messages→anthropic (c=32) | 14.9 ms | 48.4 ms | +14.2 ms | 1,675 | — | 0.29 | 24 MB | 0.0% |
| ai-gateway messages→openai-chat (c=32) | 14.8 ms | 56.5 ms | +14.1 ms | 1,580 | — | 0.29 | 59 MB | 0.0% |
| ai-gateway messages→openai-responses (c=32) | 15.2 ms | 92.4 ms | +14.6 ms | 1,355 | — | 0.33 | 59 MB | 0.0% |
| ai-gateway messages→gemini (c=32) | 15.7 ms | 111.5 ms | +15.0 ms | 1,093 | — | 0.37 | 59 MB | 0.0% |
| direct chat (c=32) | 0.5 ms | 8.1 ms | — | 17,034 | — | — | — | 0.0% |
| direct responses (c=32) | 0.8 ms | 8.8 ms | — | 13,422 | — | — | — | 0.0% |
Measured on 2026-11-15 at commit 2a091a57; source: gwbench, the last of four alternating repetitions of T077.001 (spread over all four in How performance is measured); ai-gateway is commit 2a091a57 and ai-gateway-54414f9 the 2026-10-26 baseline, which serves only the same-protocol cells; each overhead is against the direct target of the same client dialect.
Translated cells, realistic upstream, stream: concurrency 32
Section titled “Translated cells, realistic upstream, stream: concurrency 32”TTFT 300 ms and a token every 20 ms, 16 tokens, PostgreSQL per request; same cells as above (T077.001).
| Target | p50 | p99 | overhead p50 | req/s | TTFT p50 | CPU ms/req | peak mem | errors |
|---|---|---|---|---|---|---|---|---|
| direct messages (c=32) | 674.0 ms | 879.3 ms | — | 46 | 309.6 ms | — | — | 0.0% |
| ai-gateway chat→openai-chat (c=32) | 690.8 ms | 742.1 ms | +14.7 ms | 46 | 325.2 ms | 2.72 | 68 MB | 0.0% |
| ai-gateway-54414f9 chat→openai-chat (c=32) | 685.5 ms | 872.6 ms | +9.4 ms | 46 | 323.8 ms | 2.54 | 24 MB | 0.0% |
| ai-gateway chat→openai-responses (c=32) | 686.6 ms | 726.4 ms | +10.5 ms | 46 | 322.5 ms | 3.77 | 67 MB | 0.0% |
| ai-gateway chat→anthropic (c=32) | 693.6 ms | 742.2 ms | +17.5 ms | 46 | 323.9 ms | 3.64 | 67 MB | 0.0% |
| ai-gateway chat→gemini (c=32) | 687.6 ms | 731.1 ms | +11.5 ms | 46 | 325.5 ms | 4.15 | 68 MB | 0.0% |
| ai-gateway responses→openai-responses (c=32) | 693.6 ms | 737.8 ms | +18.4 ms | 46 | 323.1 ms | 2.87 | 68 MB | 0.0% |
| ai-gateway-54414f9 responses→openai-responses (c=32) | 686.1 ms | 729.7 ms | +10.9 ms | 46 | 322.9 ms | 2.84 | 24 MB | 0.0% |
| ai-gateway responses→openai-chat (c=32) | 684.9 ms | 742.1 ms | +9.8 ms | 46 | 324.7 ms | 3.43 | 64 MB | 0.0% |
| ai-gateway responses→anthropic (c=32) | 688.0 ms | 743.5 ms | +12.8 ms | 46 | 322.8 ms | 4.21 | 66 MB | 0.0% |
| ai-gateway responses→gemini (c=32) | 684.2 ms | 737.5 ms | +9.1 ms | 47 | 326.5 ms | 4.92 | 67 MB | 0.0% |
| ai-gateway messages→anthropic (c=32) | 685.0 ms | 740.3 ms | +11.0 ms | 46 | 323.1 ms | 2.60 | 67 MB | 0.0% |
| ai-gateway-54414f9 messages→anthropic (c=32) | 686.1 ms | 739.6 ms | +12.2 ms | 46 | 325.9 ms | 2.55 | 25 MB | 0.0% |
| ai-gateway messages→openai-chat (c=32) | 691.8 ms | 764.4 ms | +17.8 ms | 46 | 326.3 ms | 3.31 | 63 MB | 0.0% |
| ai-gateway messages→openai-responses (c=32) | 688.8 ms | 741.8 ms | +14.8 ms | 46 | 323.4 ms | 4.44 | 66 MB | 0.0% |
| ai-gateway messages→gemini (c=32) | 690.7 ms | 732.7 ms | +16.8 ms | 46 | 325.9 ms | 4.87 | 68 MB | 0.0% |
| direct chat (c=32) | 676.1 ms | 882.9 ms | — | 46 | 310.8 ms | — | — | 0.0% |
| direct responses (c=32) | 675.1 ms | 841.5 ms | — | 47 | 311.6 ms | — | — | 0.0% |
Measured on 2026-11-15 at commit 2a091a57; source: gwbench, the last of four alternating repetitions of T077.001 (spread over all four in How performance is measured); ai-gateway is commit 2a091a57 and ai-gateway-54414f9 the 2026-10-26 baseline, which serves only the same-protocol cells; each overhead is against the direct target of the same client dialect.
How to update
Section titled “How to update”Run the scenario with only this gateway and the direct baseline as targets: gwbench -record docs/performance/results.json -scenario <id> -title "..." -commit $(git rev-parse --short HEAD). gwbench writes the raw run into the JSON. Then run python3 scripts/render-performance.py, which regenerates this page; the gate fails if the page is not up to date with the JSON.