|
| 1 | +# Apple Login Benchmark |
| 2 | + |
| 3 | +This benchmark measures issue #323: repeated Apple provider round trips on the returning Apple User login path. |
| 4 | + |
| 5 | +## Scenario |
| 6 | + |
| 7 | +- Endpoint: `POST /oauth2/apple/login` |
| 8 | +- Primary path: returning Apple User, warm Apple key cache |
| 9 | +- Seeded Apple subject: `bench-apple-user` |
| 10 | +- Apple provider: local stub, not the real Apple network |
| 11 | +- Stub delay: |
| 12 | + - `GET /auth/keys`: 80 ms |
| 13 | + - `POST /auth/token`: 300 ms |
| 14 | + |
| 15 | +## Why the Apple provider is stubbed |
| 16 | + |
| 17 | +The primary comparison should isolate backend request-path behavior. Real Apple calls include DNS, TLS, internet routing, and provider-side variability, so they are useful as smoke checks but not as the main before/after evidence. |
| 18 | + |
| 19 | +## Run |
| 20 | + |
| 21 | +Install `k6` first if it is not already available: |
| 22 | + |
| 23 | +```bash |
| 24 | +brew install k6 |
| 25 | +``` |
| 26 | + |
| 27 | +Run from the repository root: |
| 28 | + |
| 29 | +```bash |
| 30 | +scripts/benchmarks/apple-login/run.sh before quick |
| 31 | +scripts/benchmarks/apple-login/run.sh after quick |
| 32 | +``` |
| 33 | + |
| 34 | +Full evidence runs: |
| 35 | + |
| 36 | +```bash |
| 37 | +scripts/benchmarks/apple-login/run.sh before full |
| 38 | +scripts/benchmarks/apple-login/run.sh after full |
| 39 | +``` |
| 40 | + |
| 41 | +The script starts an isolated MySQL container, starts the Apple stub, starts the backend with the `bench` Spring profile, seeds the returning Apple User, runs k6, and writes results. |
| 42 | + |
| 43 | +The script does not run `git checkout`. Measure the checkout you have selected, and use `before` or `after` only as the result label. |
| 44 | + |
| 45 | +## Defaults |
| 46 | + |
| 47 | +- Database container: `ontime-bench-mysql` |
| 48 | +- Database: `ontime_bench` |
| 49 | +- MySQL port: `127.0.0.1:3307` |
| 50 | +- Backend port: `127.0.0.1:18081` |
| 51 | +- Apple stub port: `127.0.0.1:18080` |
| 52 | +- Quick mode: 1 run per concurrency |
| 53 | +- Full mode: 10 runs per concurrency |
| 54 | +- Warmup: 2 minutes |
| 55 | +- Measurement: 5 minutes |
| 56 | +- Concurrency: 1, 10, 20 |
| 57 | + |
| 58 | +Override example: |
| 59 | + |
| 60 | +```bash |
| 61 | +WARMUP_DURATION=10s MEASUREMENT_DURATION=30s SCENARIOS="1" RUNS=1 \ |
| 62 | + scripts/benchmarks/apple-login/run.sh before quick |
| 63 | +``` |
| 64 | + |
| 65 | +## Results |
| 66 | + |
| 67 | +Results are written under: |
| 68 | + |
| 69 | +```text |
| 70 | +scripts/benchmarks/apple-login/results/<timestamp>-<label>-<mode>/ |
| 71 | +``` |
| 72 | + |
| 73 | +Each result directory contains: |
| 74 | + |
| 75 | +- `k6-*.json`: k6 measurement summary |
| 76 | +- `stub-*.json`: Apple provider hit count during measurement |
| 77 | +- `summary.csv`: joined p50/p95/p99, error rate, and provider calls/request |
| 78 | +- `backend.log`: backend logs for the run |
| 79 | +- `apple-stub.log`: Apple stub logs for the run |
| 80 | + |
| 81 | +Use `docs/performance/apple-login-323.md` for the human-readable comparison table. |
| 82 | + |
| 83 | +## Acceptance Gate |
| 84 | + |
| 85 | +Primary scenario: returning Apple User, warm cache, concurrency 1. |
| 86 | + |
| 87 | +- JWKS network calls/request: `before 1.0 -> after 0.0` |
| 88 | +- Apple token exchange calls/request: `before 1.0 -> after 0.0` |
| 89 | +- Error rate: `0%` |
| 90 | +- p95 latency: `after <= before * 0.70` |
| 91 | + |
| 92 | +Secondary scenarios: returning Apple User, concurrency 10 and 20. |
| 93 | + |
| 94 | +- Error rate: `0%` |
| 95 | +- Apple token exchange calls/request: `after 0.0` |
| 96 | +- p95 latency: `after <= before` |
0 commit comments