Skip to main content

Overview

GoAkt supports multiple clusters across datacenters. A pluggable control plane (NATS JetStream or etcd) propagates topology and placement decisions across sites. Actors can be spawned or messaged across DCs. Each datacenter runs its own cluster; the control plane coordinates which DCs are active and where to route cross-DC traffic.

Architecture

Multi-Datacenter Architecture - DC-1 and DC-2 clusters communicate via a Control Plane (NATS JetStream or etcd) for registration, heartbeats, and cross-DC messaging
  • Control plane — Manages datacenter registration, heartbeats, state transitions, and event watching. Implementations: NATS JetStream, etcd.
  • DC leader — Only the cluster leader in each DC runs the datacenter controller. It registers the local DC with the control plane using cluster members’ remoting addresses.
  • DataCenterRecord — Each DC has a record: ID, metadata (Name, Region, Zone, Labels), Endpoints (remoting addresses), State, LeaseExpiry, Version.

When to use

  • Geographic distribution — Run actors close to users or data in different regions.
  • Disaster recovery and failover — Replicate or fail over to another DC.
  • DC-aware placement — Spawn actors in a specific datacenter via SpawnOn with WithDataCenter.

Control Planes

NATS

etcd

Configuration

Multi-DC requires cluster mode. Configure the datacenter via WithDataCenter on the cluster config:
Endpoints for cross-DC routing are not set in config; the cluster leader registers the local DC with the control plane using cluster members’ remoting addresses.

Datacenter config options

Data center states

Records are leased; Heartbeat renews the lease. Expired records should not be routed to.

DC-aware actor placement

Use SpawnOn with WithDataCenter to spawn an actor in a specific datacenter:
Placement: the target is one of the target DC’s DataCenterRecord.Endpoints, selected uniformly at random. Which node runs the actor depends on what that DC registered—if it registered all nodes’ remoting addresses, the actor is placed on a random node in that DC. The actor kind must be registered on the target DC’s actor systems; otherwise the remote node returns ErrTypeNotRegistered.

Messaging across DCs

Once an actor is spawned (locally or in another DC), messaging is location-transparent. Use Tell, Ask, Request as usual; the framework routes to the correct node. Grains can also be addressed by identity across DCs when multi-DC is enabled: the system uses the control plane’s cached active datacenter records and attempts delivery to the first endpoint that successfully handles the request.

Readiness and errors

Custom control plane

Implement the datacenter.ControlPlane interface:
  • Register, Heartbeat, SetState, ListActive, Watch, Deregister
See datacenter/controlplane/nats and datacenter/controlplane/etcd as reference implementations. Wire it in by passing the control plane to the datacenter config when creating the actor system.

See also