Skip to content

Quantize auction transport timeouts to stabilize Fastly backend names#865

Open
prk-Jr wants to merge 1 commit into
mainfrom
quantize-auction-transport-timeouts
Open

Quantize auction transport timeouts to stabilize Fastly backend names#865
prk-Jr wants to merge 1 commit into
mainfrom
quantize-auction-transport-timeouts

Conversation

@prk-Jr

@prk-Jr prk-Jr commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Fastly dynamic backend names deliberately embed the first-byte and between-bytes timeouts so a registration can never be silently reused with a different transport configuration. But deriving those timeouts from the remaining wall-clock auction budget minted a new backend name on nearly every request — defeating cross-request TCP/TLS connection reuse to bidder hosts (Fastly pools connections per backend name) and accumulating registrations toward the per-service dynamic backend limit.
  • Compute the effective transport timeout in three regimes: the provider's configured timeout verbatim when the budget allows (a constant, already name-stable), the remaining budget floored to 250ms buckets when the budget is the binding constraint, and exact passthrough for sub-quantum remainders so publishers with sub-250ms configured budgets keep launching. The value feeds both the backend name and the registered configuration, so they cannot diverge; rounding down never extends a transport cap past the auction deadline, which the mediator and dispatched-collect paths rely on to bound the </body> hold.
  • Pin predict_name == ensure on the Fastly platform backend with a Viceroy test, since the orchestrator maps SSP responses back to providers by predicted backend name.

Changes

File Change
crates/trusted-server-core/src/auction/orchestrator.rs Add TRANSPORT_TIMEOUT_QUANTUM_MS, quantize_transport_timeout_ms, and effective_transport_timeout_ms; apply at the four provider-launch sites (parallel, dispatch, synchronous mediator, collect-path mediator); extend the test stub with an optional timeout recorder and add quantization, sub-quantum-passthrough, and mediator-budget tests
crates/trusted-server-adapter-fastly/src/platform.rs Add predict_name_matches_ensured_backend_name test pinning the predicted name to the registered name for an identical spec

Closes

Closes #847

Test plan

  • cargo test-fastly && cargo test-axum
  • cargo clippy-fastly && cargo clippy-axum
  • cargo fmt --all -- --check
  • JS tests: cd crates/trusted-server-js/lib && npx vitest run
  • JS format: cd crates/trusted-server-js/lib && npm run format
  • Docs format: cd docs && npm run format
  • WASM build: cargo build --package trusted-server-adapter-fastly --release --target wasm32-wasip1
  • Manual testing via fastly compute serve
  • Other: cargo test-cloudflare && cargo test-spin, cargo clippy-cloudflare && cargo clippy-cloudflare-wasm && cargo clippy-spin-native && cargo clippy-spin-wasm, and the integration parity suite (cargo test --manifest-path crates/trusted-server-integration-tests/Cargo.toml --test parity) all pass

Checklist

  • Changes follow CLAUDE.md conventions
  • No unwrap() in production code — use expect("should ...")
  • Uses tracing macros (not println!)
  • New code has tests
  • No secrets or credentials committed

Fastly dynamic backend names embed the first-byte and between-bytes
timeouts so a registration can never be silently reused with a different
transport configuration. Deriving those timeouts from the remaining
wall-clock auction budget minted a new backend name on nearly every
request, defeating cross-request TCP/TLS connection reuse (Fastly pools
connections per backend name) and accumulating registrations toward the
per-service dynamic backend limit.

Compute the effective transport timeout from the configured provider
timeout verbatim when the budget allows, floor the budget-bound value to
250ms buckets otherwise, and pass sub-quantum remainders through exactly
so publishers with sub-250ms configured budgets keep launching. The
quantized value feeds both the backend name and the registered
configuration, so they cannot diverge. Rounding down never extends a
transport cap past the auction deadline, which the mediator and
dispatched-collect paths rely on to bound the </body> hold.

Also add a Fastly platform test pinning predict_name == ensure for the
same spec, since the orchestrator maps responses back to providers by
predicted backend name.

Fixes #847
@prk-Jr prk-Jr self-assigned this Jul 8, 2026

@ChristianPavilonis ChristianPavilonis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review:

Review Summary

Reviewed PR #865 against main, focusing on the timeout quantization logic in crates/trusted-server-core/src/auction/orchestrator.rs and the Fastly backend-name consistency test in crates/trusted-server-adapter-fastly/src/platform.rs. I did not find blocking correctness, security, data-loss, authorization, or severe compatibility issues.

Findings

P0 / Blockers

None.

P1 / High

None.

P2 / Medium

None.

P3 / Low

None.

CI / Existing Reviews

gh pr checks 865 reports all checks passing, including Rust, JS/TS, formatting, integration, browser, CodeQL, and cross-adapter parity jobs. Existing review/comment queries did not show prior review feedback to duplicate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor Fastly backend name to exlcude extraneous identifiers

2 participants