Multi-Datacenter KV Relay Configuration

CLI arguments, environment variables, resource limits, and diagnostic endpoints
View as Markdown

Experimental. The DC KV Relay collects worker KV-cache events within a data center and publishes compact cache-locality, serving-readiness, and load information for external consumers.

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

CLI Arguments

ArgumentEnvironment variableDefaultMeaning
--dc-idDYN_DC_IDRequiredLogical data-center 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.
--helpNonePrint CLI usage and exit.

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.

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 DC KV Relay. Relay’s CLI does not accept the Frontend’s runtime CLI flags; configure the runtime through its environment variables.

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_MS1000Load publication window.
DYN_RELAY_LOAD_FANOUT_CAPACITY16Buffered load updates 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 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>.kv_dc_relay_<dc-hash>, where dc-hash is the first 32 hexadecimal characters of SHA-256 over the UTF-8 DC ID. These are not HTTP paths or WAN RPCs.

EndpointAvailabilityRequest and response
healthAlwaysEmpty request; reports healthy, shutdown state, endpoint counts, and WAN state/errors.
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. 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