Skip to content

node: idle warm connections hold dispatch permits for 30 s and can fill max_concurrent_handlers at scale #2541

Open

Description

@thiras

Context

Since #2475 a node keeps one warm cdn/dht/v1 connection per peer and one warm cdn/client/v1 connection per upstream. The DHT server waits 30 s between streams before it closes an idle connection (IDLE_BETWEEN_STREAMS, equal to the cdn/client/v1 reaper APP_IDLE_TIMEOUT), then flushes conn.closed() for up to 3 s.

The dispatch permit is acquired once per connection and held for the whole serve (crates/node/src/handlers/dht.rs, handlers/client/dispatch.rs). One ConnectionLimiter is shared by the probe, DHT and client handlers, with max_concurrent_handlers defaulting to 256. Before #2475 a node-to-node permit was held for about one RTT; now an idle warm connection holds it for 30 s.

Problem

Each peer pair holds about two idle permits in steady state (one per ALPN per direction). Republish sweeps and bucket refresh reach most of the routing table, so above roughly 128 active nodes idle node-to-node connections alone can take all 256 permits. A paying client then gets global-full. The project rule is that drop-cases must hold at every scale, so this cannot stay a post-deploy metric watch.

Options

  1. Acquire the DHT permit per stream rather than per connection. The DHT serve loop is sequential, so a per-stream permit still bounds concurrent work; an idle warm connection then costs no permit.
  2. Give idle warm connections a small pool of their own, separate from the client cap.
  3. Have the requester close a pooled DHT connection after a shorter idle time of its own, well under 30 s.

Option 1 is the smallest change and keeps the #845 permit-hygiene argument (the 256-request and 5-minute caps stay).

Watch meanwhile

max_over_time(decdn_dispatch_in_flight[1d]) on the testnet after #2475 deploys; expect headroom under 256 at 7 nodes, which says nothing about scale.

Spun out of the #2475 review.

Activity

  1. added
    design:missing-decision
    area:node
    on Oct 19, 2026
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

    area:nodedesign:missing-decision

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    • Status
      Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions