Skip to content

Egress-aware sourcing: prefer a cached peer over own backend egress for own-namespace content #1758

Closed as not planned

Description

@alpergundogdu

Sibling axis split out of #1755 (refuse-to-serve). This is a sourcing/routing optimization, not a refusal — an origin never refuses its own namespace; its only economic knob for its own content is where to source the bytes.

The insight

An origin re-fetching its own blob from an HTTP/S3 backend pays real egress (S3 ≈ $0.09/GB). Gross client rate is ~$0.01/GB (ADR 026), so serving own content straight from S3 loses ~$0.084/GB every time. A cached copy on a peer costs protocol price (~tracks $0.01/GB) — roughly 9× cheaper than own S3 egress. The CDN economics only work because origin egress is paid once to seed, then amortized over cheap cached re-serves. So an origin should prefer pulling its own content from a cheaper cached peer over re-paying backend egress.

Free backends (FS, R2 free-egress) make this a no-op; expensive-egress backends (S3, metered HTTP) make it dominant.

Already mechanically possible

Namespace is routing-only (ADR 002; the authorized-origin serve gate was removed). Any node already pulls and serves any hash via the paid pull-through path. Content is BLAKE3-addressed and immutable, so a peer's copy of hash H is byte-identical — no freshness/staleness risk. So this needs a routing preference, not a new capability.

Proposed shape

  • Model the own backend as one priced candidate with a per-origin egress cost config (origin_egress_per_mb, default 0 = today's behavior for free backends).
  • On an own-namespace miss, prefer the cheapest verified source across {own backend, peers holding H}.
  • Keep the backend a non-refusable seeding fallback — someone must pay to seed the first copy, and the origin is the natural seeder. Own namespace is never made unavailable.
  • Opt-in per origin — some origins prefer self-sufficiency (not depending on competitors' caches) even when a peer is cheaper.

Guardrails / open questions

Not part of #1755.

Activity

  1. added
    kind:feature
    design:economics
    rust
    prio:medium
    on Aug 20, 2026
  2. moved this from Backlog to Ready in deCDNon Aug 20, 2026
  3. moved this from Ready to In progress in deCDNon Aug 20, 2026
  4. moved this from In progress to Ready in deCDNon Aug 20, 2026
  5. removed their assignment
    on Aug 20, 2026
  6. moved this from Ready to Blocked in deCDNon Aug 30, 2026
  7. thiras commented on Sep 26, 2026

    @thiras
    Contributor

    Closing as not planned. The saving is real but narrow, and existing rules already cover most of it. The burden is on adding a mechanism, and this one does not clear it.

    Current behaviour. The miss path tries the configured origin backends first and asks paid peers only last (crates/node/src/runtime/mod.rs, origin-chain assembly). An origin always refetches its own content from its backend. ADR 041 § Scope leaves own-namespace sourcing as a separate concern, and that stays unowned on purpose.

    Why it stays out

    1. The "$0.084/GB loss" assumes a misconfigured origin. ADR 003 § origin backend economics already tells an S3-backed origin to price above market or use a backend with free egress (R2, B2, Wasabi). If the origin's rate is above its egress cost, refetching from the backend still makes a profit. Sourcing from a peer would only raise the margin; it would not prevent a loss.
    2. Client ranking already covers most of it. The saving applies only when the origin has evicted its own blob, a peer still holds the copy it got from that origin, and the client picked the origin even though clients rank nodes by price and RTT and origins price higher. Client-side ranking already sends that traffic to the cheaper holder.
    3. It would slow down seeding. Checking peers first adds a DHT lookup and probe round to every own-namespace miss. That includes blobs no peer holds yet: the lookup comes back empty and the node falls back to its backend. That delay lands on seeding, which is the job an origin exists for.
    4. No origin needs it yet. No known origin runs on a paid-egress backend today.

    If this comes back. Only a real origin on a paid-egress backend should reopen it. The smallest version:

    • One knob, cache.origin_egress_per_mb, defaulting to 0 (current behaviour).
    • When it is above 0: for a miss the backend confirms is its own content, pull only from peers found as holders in the DHT, paying at most min(origin_egress_per_mb, max_rate_per_mb). Put a short timeout on discovery, then fall back to the backend.
    • Do not use the fallback to the on-chain origin list or ADR 037's fallback to non-holding relays. The peer-pull code already drops any peer whose probe says it does not hold the blob, so there is no loop risk.
    • Do not apply ADR 041's margin gate.
    • Record it in ADR 041 § Scope or ADR 003's backend-economics section. It does not need a new ADR.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    design:economicskind:featureprio:mediumrust

    Type

    No type

    Fields

    Priority

    Medium

    Projects

    • Status
      Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions