Skip to navigation

Pool Relay Configuration

CLI arguments, environment variables, resource limits, and diagnostic endpoints
View as MarkdownOpen in Claude

Experimental. The Pool Relay (formerly KV DC Relay) collects worker KV-cache events within a discovery cluster and publishes compact cache-locality, serving-readiness, and load information for external consumers.

This reference describes python -m dynamo.pool_relay. For deployment, see Deploy the Pool Relay; for an overview and architecture, see Pool Relay Concepts.

CLI Arguments

ArgumentEnvironment variableDefaultMeaning
--cluster-idDYN_CLUSTER_IDRequiredDiscovery-cluster identity. Keep stable across restarts; must be nonempty without surrounding whitespace.
--namespacesDYN_RELAY_NAMESPACESAll visible Dynamo namespacesComma-separated Dynamo namespace allowlist.
--namespace-filterNoneUnsetLegacy single-namespace form of --namespaces.
--watch-allDYN_RELAY_WATCH_ALLEnabled when no scope is setInclude model cards from every Dynamo namespace visible to the discovery backend.
--endpoint-prefixDYN_RELAY_ENDPOINT_PREFIXESNo prefix filterRepeat the CLI option, or use a comma-separated environment value. Match namespace/component/endpoint segments.
--expected-unique-blocksDYN_RELAY_EXPECTED_UNIQUE_BLOCKS1048576Positive expected number of unique blocks per pool; sizes the CKF, not a global Relay memory limit.
--bindDYN_RELAY_BINDNo listenerPlaintext gRPC socket address, such as 127.0.0.1:5561 or [::1]:5561. Requires a numeric IP and port.
--global-discovery-urlDYN_RELAY_GLOBAL_DISCOVERY_URLUnsetRoot of the Global Discovery Service, such as http://global-discovery:8080/. The Relay reads the Global Router replica list from it every 5 seconds. When a read fails, it keeps the last list and reports why in the health field global_routers_stale_reason. When unset, the Relay reads no list.
--helpNone—Print CLI usage and exit.
--routing-poolDYN_RELAY_ROUTING_POOLUnsetPublish this DGD’s state to every discovered Global Router as <cluster>/<Kubernetes namespace>/<DGD name>. The cluster must match --cluster-id. Requires --global-discovery-url, --bind, and --routing-pool-region.
--routing-pool-regionDYN_RELAY_ROUTING_POOL_REGIONUnsetRegion the routing pool is registered in with Global Discovery, such as us-east-1. Required with --routing-pool.
--routing-pool-frontendsDYN_RELAY_ROUTING_POOL_FRONTENDSNoneComma-separated HTTP(S) frontend URLs that Global Routers send the routing pool’s requests to. Requires --routing-pool. Set it when Global Discovery runs with --pool-discovery registrations: a pool without frontends receives no requests. With mcs or karmada, Global Discovery takes the frontends from MCS and ignores these.

The protocol and gRPC server are included in the standard build. Omitting --bind disables only the WAN listener; local discovery and pool maintenance still run. Relay has no TLS flags or certificate configuration. Protect a listener across a trust boundary with an optional external sidecar.

With --routing-pool, each router receives the current catalog, serving readiness, serving load, and KV load, followed by updates. Router endpoints returned by GET /routers must address each replica’s receiving gRPC listener, rather than its HTTP API. Reconnecting sends a fresh snapshot.

The Relay also registers the routing pool with POST /pools on the Global Discovery Service and renews the registration on the interval the service’s lease sets. Global Discovery lists the pool only while the registration is current, in every mode. With mcs or karmada, it also requires --cluster-id to be the cluster name MCS uses.

A registration names one model. The Relay keeps the registered model while it is in its serving topology, in any state, so a second model rolling out does not move the registration and replicas stay on the same model. Otherwise it registers the one Ready model, or the only model while none is Ready. With no model, or with several to choose from, it registers nothing. Global Routers route the pool only by its registered model, not by aliases or adapters. The health field routing_pool_unregistered_reason says why the pool is not registered, including a failed call, which the Relay retries. On shutdown the Relay stops renewing, and the pool leaves GET /pools when the lease ends.

The routing pool names a Kubernetes DGD. Scope the Relay’s discovery sources to that DGD; the routing key does not filter discovery. Dynamo runtime namespaces in readiness and load messages can differ from the Kubernetes namespace in this key.

Configure Global Router discovery probes independently of pool availability. The frontend’s /live endpoint is available before Relays connect; /health requires a routable pool. Using pool-dependent readiness to discover routers would prevent Relays from finding a new router.

Precedence and Scope

CLI values override the corresponding environment values. A CLI scope option replaces the whole environment scope: --namespaces, --namespace-filter, and --watch-all are mutually exclusive. Likewise, a CLI prefix list replaces, rather than extends, the environment prefix list.

  • Lists must contain nonempty, unique entries. Comma-separated lists trim item whitespace.
  • Prefixes must match whole endpoint segments, not arbitrary string prefixes. With an explicit namespace allowlist, every prefix must belong to one of those namespaces.
  • DYN_RELAY_NAMESPACES cannot be combined with a true DYN_RELAY_WATCH_ALL.
  • Boolean environment values accept 1/0, true/false, yes/no, or on/off, ignoring case and surrounding whitespace. Explicit DYN_RELAY_WATCH_ALL=false requires a namespace allowlist.
  • With neither a CLI nor an environment scope, the Relay watches all visible Dynamo namespaces.

For example, production, production.backend, and production.backend.generate select successively narrower endpoint scopes. production.back does not match production.backend.

Dynamo namespaces are logical discovery scopes, not Kubernetes namespaces. The current Kubernetes discovery backend watches only the Relay pod’s Kubernetes namespace. Neither --watch-all nor --namespaces expands that Kubernetes watch.

Runtime Environment

Relay uses the shared DistributedRuntime, created by @dynamo_worker().

VariableDefaultRelay usage
DYN_NAMESPACEdynamoNamespace of Relay’s own runtime endpoints; does not select watched worker namespaces.
DYN_DISCOVERY_BACKENDetcdShared discovery backend; set kubernetes for the Kubernetes how-to.
DYN_REQUEST_PLANEtcpShared runtime request transport, independent of the WAN gRPC listener.
DYN_EVENT_PLANEBackend-dependentMatch worker event transport: zmq for direct TCP events without NATS, or nats. Set explicitly in deployment manifests.
NATS_SERVERnats://localhost:4222Address of the workers’ NATS service when using the NATS event plane.
DYN_SYSTEM_PORTDisabled (-1)Enables the runtime HTTP health and metrics server when set to a nonnegative port.

For connection settings and runtime defaults, see Runtime Configuration. For direct event transport and TCP response-stream addressing, see TCP-only deployment. For Kubernetes pod identity and RBAC, see Deploy the Pool Relay. Relay’s CLI does not accept the Frontend’s runtime CLI flags; configure the runtime through its environment variables.

Serving-Load Publishers

SubscribeServingLoad aggregates load that frontends and routers publish only when DYN_SERVING_LOAD_PUBLISH is true. It is off by default, so deployments without a Relay run no background serving-load publishing. Set it on the processes that feed the Relay, not on the Relay itself:

ProcessPublishes
Frontend, including its embedded KV routerPer-model request and token load once per second, and the embedded router’s scheduler load
Standalone KV routerScheduler load of every worker rank once per second

Set it on all of them. The Relay cannot see a frontend or router that does not publish, so when only some do, their load reads as the complete load. Without it anywhere, every serving-load view is UNAVAILABLE, and after 30 seconds the Relay logs a warning naming the variable.

Producer Tuning

These environment-only overrides also work without a WAN listener. All values must be positive integers. Unknown DYN_RELAY_* names are not consumed by the launcher; check spelling.

VariableDefaultMeaning
DYN_RELAY_PUBLICATION_THRESHOLD16Primary-residency KV events processed before a publication; not changed buckets or bytes.
DYN_RELAY_PUBLICATION_DELAY_MS1Publication coalescing delay in milliseconds.
DYN_RELAY_RECOVERY_ATTEMPT_TIMEOUT_MS30000Timeout for a worker recovery attempt.

The capacity selected by --expected-unique-blocks must fit the CBI1 maximum of 16777216 buckets. The Rust producer rejects a larger derived CKF layout at startup.

WAN Tuning

Every variable below requires --bind or DYN_RELAY_BIND, including publication-resource overrides that are owned by the universal publisher. Setting one without a listener is a startup error. All values must be positive integers; byte limits use bytes, not MiB.

Transport and Projection Timing

VariableDefaultMeaning
DYN_RELAY_MAX_MESSAGE_BYTES8388608Maximum gRPC encoding and decoding message size.
DYN_RELAY_KEEPALIVE_INTERVAL_MS20000HTTP/2 keepalive interval.
DYN_RELAY_KEEPALIVE_TIMEOUT_MS10000HTTP/2 keepalive timeout.
DYN_RELAY_POOL_HEARTBEAT_INTERVAL_MS10000Pool-stream heartbeat interval after snapshot bootstrap.
DYN_RELAY_READINESS_HEARTBEAT_INTERVAL_MS10000Interval for repeating the current readiness snapshot.
DYN_RELAY_SNAPSHOT_PROGRESS_TIMEOUT_MS60000Per-frame progress deadline while producing the initial snapshot.
DYN_RELAY_LOAD_WINDOW_MS1000Pool-load and serving-load publication window.
DYN_RELAY_LOAD_FANOUT_CAPACITY16Buffered updates per load stream type for fanout.

Universal Publication Resources

These limits belong to the publisher; the Python launcher exposes their overrides with WAN enabled.

VariableDefaultMeaning
DYN_RELAY_PUBLICATION_QUEUE_CAPACITY16Pool-subscriber queue message bound.
DYN_RELAY_PUBLICATION_QUEUE_BYTES16777216Pool-subscriber queue byte bound.
DYN_RELAY_PUBLICATION_ENCODING_CONCURRENCY2Concurrent snapshot encoders.
DYN_RELAY_MAX_INITIALIZED_POOL_HUBS64Resident initialized hubs, including idle hubs eligible for eviction.

Stream Admission

VariableDefaultMeaning
DYN_RELAY_MAX_CATALOG_SUBSCRIBERS64Concurrent catalog streams.
DYN_RELAY_MAX_POOL_STREAMS_TOTAL64Total active pool streams.
DYN_RELAY_MAX_SUBSCRIBERS_PER_POOL64Subscribers attached to one pool.
DYN_RELAY_MAX_READINESS_SUBSCRIBERS64Concurrent readiness streams.
DYN_RELAY_MAX_LOAD_SUBSCRIBERS64Concurrent pool-load streams.
DYN_RELAY_MAX_SERVING_LOAD_SUBSCRIBERS64Concurrent serving-load streams.

Validation Limits

WAN timer values cannot exceed 31536000000 ms. Load fanout capacity cannot exceed 65536. Channel and semaphore capacities must also fit their underlying Tokio limits. The message limit must be at least 4259904 bytes and the queue byte bound at least 4194624 bytes, so each can hold a maximum CBI1 frame plus its required overhead.

A complete snapshot chunk contains 4 MiB of bucket words plus framing. Configure clients and sidecars to accept the server’s message size; tonic’s default 4 MiB receive limit is insufficient for a maximum chunk. Resource exhaustion and snapshot progress deadlines are described in the gRPC contract.

Diagnostic Endpoints

The component registers Dynamo runtime endpoints under <DYN_NAMESPACE>.pool_relay_<cluster-hash>, where cluster-hash is the first 32 hexadecimal characters of SHA-256 over the UTF-8 cluster ID. These are not HTTP paths or WAN RPCs.

EndpointAvailabilityRequest and response
healthAlwaysEmpty request; reports healthy, shutdown state, endpoint counts, WAN state/errors, global_discovery_enabled, global_routers_stale_reason, and routing_pool_unregistered_reason.
statsckf-diagnostics build featureEmpty request; returns detailed endpoint/pool statistics.
snapshotckf-diagnostics build featureRequires serving_endpoint; returns that endpoint’s diagnostic snapshot.

The WAN listener also exposes gRPC reflection and the standard gRPC health service for dynamo.kvrelay.v1.KvEventRelay. The gRPC service name changes in a separate update. Transport readiness does not prove that pools have been discovered or that a model can serve requests. Inspect catalog and serving-readiness streams separately. Terminal host or transport failures stop the component with a nonzero exit status.

Sources