|
1 | 1 | # Nexus Gateway |
2 | 2 |
|
3 | | -[](.github/workflows/ci.yml) |
4 | | -[](.github/workflows/go-ci.yml) |
| 3 | +[](.github/workflows/ci.yml) |
| 4 | +[](.github/workflows/go-ci.yml) |
5 | 5 | [](./scripts/check-go-coverage.sh) |
6 | 6 | [](./CHANGELOG.md) |
7 | 7 | [](./LICENSE) |
@@ -102,6 +102,52 @@ Nexus is designed so that the compliance layer adds as little latency as possibl |
102 | 102 |
|
103 | 103 | **Quota accounting is write-behind.** Per-request quota costs accumulate in-process and flush to Redis on a 250ms interval, removing the synchronous Redis round-trip from the hot path. Configurable back to synchronous mode (`NEXUS_QUOTA_WRITE_BEHIND=0`) for strict accounting requirements. |
104 | 104 |
|
| 105 | +### Benchmarking & load-testing toolkit |
| 106 | + |
| 107 | +The numbers above are produced and re-verified by a three-repo toolkit, each maintained as its own standalone repository. The load generator was previously the in-tree `tools/loadtest` and was extracted to `nexus-loadtest` (see [CHANGELOG](./CHANGELOG.md)). |
| 108 | + |
| 109 | +| Repo | Role | Key docs | |
| 110 | +|---|---|---| |
| 111 | +| **[llm-gateway-benchmark](https://github.com/AlphaBitCore/llm-gateway-benchmark)** | On-demand AWS rig (CloudFormation + Ansible) that benchmarks Nexus head-to-head against 5 other gateways (Bifrost, LiteLLM, Kong, Portkey, TensorZero) — each isolated on its own box, all hitting one shared mock upstream. Deploy to run, `delete-stack` to tear down. | [ARCHITECTURE](https://github.com/AlphaBitCore/llm-gateway-benchmark/blob/main/ARCHITECTURE.md) · [LOADTEST-RUNBOOK](https://github.com/AlphaBitCore/llm-gateway-benchmark/blob/main/docs/LOADTEST-RUNBOOK.md) · [CONTROL-BOX-RUNBOOK](https://github.com/AlphaBitCore/llm-gateway-benchmark/blob/main/docs/CONTROL-BOX-RUNBOOK.md) | |
| 112 | +| **[nexus-mock-provider](https://github.com/AlphaBitCore/nexus-mock-provider)** | High-performance mock upstream that speaks the real OpenAI / Gemini / Anthropic wire formats (streaming + non-streaming) and echoes requests back with plausible token usage. Removes the real, paid, rate-limited provider from the measurement so you benchmark the gateway, not the model. Listens on `:3062`. | [README](https://github.com/AlphaBitCore/nexus-mock-provider/blob/main/README.md) · [CONFIGURE-NEXUS](https://github.com/AlphaBitCore/nexus-mock-provider/blob/main/CONFIGURE-NEXUS.md) | |
| 113 | +| **[nexus-loadtest](https://github.com/AlphaBitCore/nexus-loadtest)** | Scenario-driven load generator for any OpenAI- or Anthropic-compatible endpoint. Simulates realistic, weighted, multi-turn traffic and reports TTFT, inter-token latency, and token throughput. Scales to tens of thousands of concurrent virtual users from one host. | [README](https://github.com/AlphaBitCore/nexus-loadtest/blob/main/README.md) · [DESIGN](https://github.com/AlphaBitCore/nexus-loadtest/blob/main/DESIGN.md) | |
| 114 | + |
| 115 | +#### Run a quick local benchmark (single gateway) |
| 116 | + |
| 117 | +Measure your local AI Gateway (`:3050`) against the mock upstream — no real provider, no cost: |
| 118 | + |
| 119 | +1. **Start the mock upstream** (in a `nexus-mock-provider` checkout): |
| 120 | + ```bash |
| 121 | + make run # serves :3062, all three specs (OpenAI / Gemini / Anthropic) |
| 122 | + ``` |
| 123 | +2. **Point Nexus at the mock.** Add a provider credential / routing rule whose upstream base URL is `http://localhost:3062` (the mock accepts any API key). See [`CONFIGURE-NEXUS.md`](https://github.com/AlphaBitCore/nexus-mock-provider/blob/main/CONFIGURE-NEXUS.md) for the exact routing setup. |
| 124 | +3. **Run the load generator** (in a `nexus-loadtest` checkout) against the gateway, authenticating with a Nexus virtual key: |
| 125 | + ```bash |
| 126 | + go run ./cmd/loadtest -config profiles/realistic.json \ |
| 127 | + -target http://localhost:3050 -vk <your-virtual-key> -out runs/ |
| 128 | + ``` |
| 129 | +4. **Read the report** at `runs/<run-id>/` — TTFT, inter-token latency, throughput, and per-tier breakdown. Use `-compare` against an earlier `summary.json` to gate regressions. |
| 130 | + |
| 131 | +#### Run the full head-to-head matrix (AWS) |
| 132 | + |
| 133 | +To compare Nexus against the other gateways on isolated boxes, use the `llm-gateway-benchmark` rig (binaries ship prebuilt in `artifacts/` — nothing compiles on-box): |
| 134 | + |
| 135 | +```bash |
| 136 | +# 1. Deploy infra |
| 137 | +aws cloudformation deploy --stack-name nexus-perf-matrix \ |
| 138 | + --template-file cloudformation/perf-matrix-stack.yaml --capabilities CAPABILITY_IAM \ |
| 139 | + --parameter-overrides KeyName=<your-key> AdminCidr=<your.ip>/32 |
| 140 | +# 2. Provision every box (host-native) |
| 141 | +scripts/gen-inventory.sh nexus-perf-matrix ~/.ssh/<your-key>.pem <region> |
| 142 | +cd ansible && ansible-playbook -i inventory.ini site.yml |
| 143 | +# 3. Run the benchmark (one gateway, all tiers → a report each) |
| 144 | +GATEWAY=nexus scripts/bench/run-tiers.sh |
| 145 | +# 4. Tear down when idle (on-demand, cost control) |
| 146 | +aws cloudformation delete-stack --stack-name nexus-perf-matrix |
| 147 | +``` |
| 148 | + |
| 149 | +Compare gateways by **TTFT delta** — the shared mock's latency cancels out, so the difference is the gateway's own overhead. Full procedure and the report-validity gate are in the rig's [LOADTEST-RUNBOOK](https://github.com/AlphaBitCore/llm-gateway-benchmark/blob/main/docs/LOADTEST-RUNBOOK.md). |
| 150 | + |
105 | 151 | --- |
106 | 152 |
|
107 | 153 | ## Architecture in one minute |
|
0 commit comments