cache: Per-client fair-share bandwidth on table uplink #54

Merged
eva merged 2 commits from cache/per-client-uplink-fair-share into main 2026-09-09 15:36:58 -05:00
Collaborator

Why

Table-tier (LAN-party floor) boxes share a thin uplink to the backroom. Today only max_requests_per_client limits concurrency, so one hungry download can still starve others on bytes/sec.

What

  • Config: uplink_bandwidth (go-units human size → bytes/sec) and max_bytes_per_client_per_sec (absolute cap). Empty/0 = off (previous unlimited behavior).
  • Fair-share: when uplink is set, active downloading clients each get ~uplink/N (min with absolute cap when both set).
  • Response body shaping via per-client golang.org/x/time/rate token buckets; limitedResponseWriter wraps content paths after special endpoints.
  • Distinct from existing concurrency semaphores (max_requests_per_client unchanged).
  • README + validate-config note for table → backroom hierarchy. Host allowlist / open-proxy posture unchanged.

How tested

  • go test -count=1 ./config/ ./steamcache/ on jumpbox (includes fair-share unit tests, absolute-cap writer timing, ServeHTTP shaping with Steam UA).

Risks

  • Very low caps can make large depot pulls appear hung to impatient clients; operators should size uplink to the real floor cable.
  • Shaping applies to HIT and MISS body bytes after special endpoints; metrics/heartbeat remain unshaped.

Rollback

git revert the merge commit (or close PR without merging).

Fixes #42

## Why Table-tier (LAN-party floor) boxes share a thin uplink to the backroom. Today only `max_requests_per_client` limits concurrency, so one hungry download can still starve others on bytes/sec. ## What - Config: `uplink_bandwidth` (go-units human size → bytes/sec) and `max_bytes_per_client_per_sec` (absolute cap). Empty/0 = off (previous unlimited behavior). - Fair-share: when uplink is set, active downloading clients each get ~`uplink/N` (min with absolute cap when both set). - Response body shaping via per-client `golang.org/x/time/rate` token buckets; `limitedResponseWriter` wraps content paths after special endpoints. - Distinct from existing concurrency semaphores (`max_requests_per_client` unchanged). - README + validate-config note for table → backroom hierarchy. Host allowlist / open-proxy posture unchanged. ## How tested - `go test -count=1 ./config/ ./steamcache/` on jumpbox (includes fair-share unit tests, absolute-cap writer timing, ServeHTTP shaping with Steam UA). ## Risks - Very low caps can make large depot pulls appear hung to impatient clients; operators should size uplink to the real floor cable. - Shaping applies to HIT and MISS body bytes after special endpoints; metrics/heartbeat remain unshaped. ## Rollback `git revert` the merge commit (or close PR without merging). Fixes https://git.s1d3sw1ped.com/s1d3sw1ped/steamcache2/issues/42
pike self-assigned this 2026-09-09 15:22:40 -05:00
pike added 1 commit 2026-09-09 15:22:41 -05:00
cache: Per-client fair-share bandwidth on table uplink
CI / vulncheck (pull_request) Successful in 20s
CI / check-and-test (pull_request) Failing after 21s
b7710de0ca
pike requested review from eva 2026-09-09 15:22:41 -05:00
Author
Collaborator

Bouncing — CI red on head b7710de0.

CI / check-and-test failed at golangci-lint (goimports ×4):

  • cmd/root.go:23
  • config/config.go:24
  • config/config_test.go:215
  • steamcache/bandwidth_test.go:96

vulncheck green. Not merging until check-and-test is green (gofmt/goimports those files and push).

Bouncing — CI red on head `b7710de0`. **CI / check-and-test** failed at **golangci-lint** (goimports ×4): - `cmd/root.go:23` - `config/config.go:24` - `config/config_test.go:215` - `steamcache/bandwidth_test.go:96` vulncheck green. Not merging until check-and-test is green (`gofmt`/`goimports` those files and push).
pike added 1 commit 2026-09-09 15:27:34 -05:00
ops: Fix goimports on fair-share bandwidth PR
CI / vulncheck (pull_request) Successful in 14s
CI / check-and-test (pull_request) Successful in 51s
CI / vulncheck (push) Successful in 14s
CI / check-and-test (push) Successful in 50s
Release Tag / release (push) Successful in 20s
25622cbf25
pike closed this pull request 2026-09-09 15:33:03 -05:00
pike deleted branch cache/per-client-uplink-fair-share 2026-09-09 15:33:03 -05:00
pike reopened this pull request 2026-09-09 15:33:26 -05:00
eva approved these changes 2026-09-09 15:36:57 -05:00
eva left a comment
Owner

Re-review after goimports fix on 25622cb.

Prior bounce (goimports ×4) fixed; CI runs 1566/1567 green (check-and-test + vulncheck). Fair-share limiter + limitedResponseWriter look sound; empty/0 config = off preserved. Merging.

Re-review after goimports fix on `25622cb`. Prior bounce (goimports ×4) fixed; CI runs 1566/1567 green (check-and-test + vulncheck). Fair-share limiter + limitedResponseWriter look sound; empty/0 config = off preserved. Merging.
eva merged commit 25622cbf25 into main 2026-09-09 15:36:58 -05:00
eva deleted branch cache/per-client-uplink-fair-share 2026-09-09 15:36:58 -05:00
Sign in to join this conversation.
No Reviewers
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: s1d3sw1ped/steamcache2#54