To maximise KV cache reuse, requests sharing the same context prefix must hit the same GPU. vLLM 0.11.0 returns vllm-num-cached-tokens in response headers.
Requirement
Implement cache-aware backend selection using rendezvous hashing on X-Poimen-Cache-Key. Log prefix cache hit stats.
Acceptance Criteria
AC1: Multiple backend addresses per model via addresses: [...] in config (backward compat with single address)
AC2: Requests with X-Poimen-Cache-Key → rendezvous-hash backend selection (same key always → same backend)
AC3: Requests without key → round-robin across backends
AC4: Failed backend excluded from routing for 30s; next-highest-score backend used (next-in-ring fallback)
AC5: X-Poimen-Cache-Key forwarded to vLLM upstream automatically
AC6: vllm-num-cached-tokens extracted from response; structured log emitted: {event,cache_key,cached_tokens,total_tokens,hit_rate}
AC7: vllm_prefix_cache_hit_tokens_total counter exported at /metrics
Files
internal/config/config.go
internal/config/loader.go
internal/proxy/proxy.go (wires scheduler from CAG-2)
internal/observability/metrics.go
internal/observability/prometheus.go
internal/logging/logger.go
## Context
To maximise KV cache reuse, requests sharing the same context prefix must hit the same GPU. vLLM 0.11.0 returns `vllm-num-cached-tokens` in response headers.
## Requirement
Implement cache-aware backend selection using rendezvous hashing on `X-Poimen-Cache-Key`. Log prefix cache hit stats.
## Acceptance Criteria
- AC1: Multiple backend addresses per model via `addresses: [...]` in config (backward compat with single `address`)
- AC2: Requests with `X-Poimen-Cache-Key` → rendezvous-hash backend selection (same key always → same backend)
- AC3: Requests without key → round-robin across backends
- AC4: Failed backend excluded from routing for 30s; next-highest-score backend used (next-in-ring fallback)
- AC5: `X-Poimen-Cache-Key` forwarded to vLLM upstream automatically
- AC6: `vllm-num-cached-tokens` extracted from response; structured log emitted: `{event,cache_key,cached_tokens,total_tokens,hit_rate}`
- AC7: `vllm_prefix_cache_hit_tokens_total` counter exported at `/metrics`
## Files
- `internal/config/config.go`
- `internal/config/loader.go`
- `internal/proxy/proxy.go` (wires scheduler from CAG-2)
- `internal/observability/metrics.go`
- `internal/observability/prometheus.go`
- `internal/logging/logger.go`
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Context
To maximise KV cache reuse, requests sharing the same context prefix must hit the same GPU. vLLM 0.11.0 returns
vllm-num-cached-tokensin response headers.Requirement
Implement cache-aware backend selection using rendezvous hashing on
X-Poimen-Cache-Key. Log prefix cache hit stats.Acceptance Criteria
addresses: [...]in config (backward compat with singleaddress)X-Poimen-Cache-Key→ rendezvous-hash backend selection (same key always → same backend)X-Poimen-Cache-Keyforwarded to vLLM upstream automaticallyvllm-num-cached-tokensextracted from response; structured log emitted:{event,cache_key,cached_tokens,total_tokens,hit_rate}vllm_prefix_cache_hit_tokens_totalcounter exported at/metricsFiles
internal/config/config.gointernal/config/loader.gointernal/proxy/proxy.go(wires scheduler from CAG-2)internal/observability/metrics.gointernal/observability/prometheus.gointernal/logging/logger.goHarness review — merged
RUN_ID:
riotpiao-poimen/homelab-frontend#44-45-46-2026-09-27T09:35ZPR: #47 (merged) Diff: 16 files +1603 / -168
Coders
Verification
go build ./... && go vet ./... && go test -race ./...→ all pass, 0 racesreviewer-sre — SIGN-OFF
0🔴 3🟡 2🔵 — queue-full logged + counted, auth-bypass warned, all 3 CAG counters at /metrics
reviewer-quality — SIGN-OFF
CRAP: ServeHTTP 9.0 ✅ authenticateV1 8.5 ✅ — all 7 ACs covered by tests
Verdict: Merged ✅