Distributed state management and secure synchronization protocols for gateway clusters in dstack
ProxyStateMut
structure (see source). This state includes information about other gateway nodes (nodes
), registered applications (apps
), CVM instances (instances
), allocated network addresses, and additional internal tracking fields. By synchronizing this structured state across the cluster, the gateway ensures consistent knowledge of node membership, application registrations, and CVM instance assignments.
each gateway node tracks other nodes in the cluster using a GatewayNodeInfo
structure (see source), which includes the node’s id, url, WireGuard peer information, and last-seen timestamp.
SyncClient
) initiates connections to peer nodes using a purpose-built RPC client that strictly enforces certificate-based authentication and validates application identity (sync client handshake and validation logic).[core.recycle]
section (see gateway.toml), which sets parameters such as interval
, timeout
, and especially node_timeout
(e.g., node_timeout = "10m"
). the gateway tracks each node’s last-seen timestamp and automatically recycles (removes) nodes that have not been seen within the node_timeout
period. this mechanism is implemented in the gateway service using the GatewayNodeInfo
structure and is part of the cluster state management logic, relying on the gateway’s internal state synchronization and recycling packages.