Modes
A GoAkt actor system runs in one of two modes:
Remoting can also be enabled without clustering for point-to-point messaging between known nodes. That middle ground
(no membership, no registry, no relocation) is covered in Remoting.
Standalone mode
In standalone mode, GoAkt runs in a single process. Actors are spawned under the user guardian and communicate through direct mailbox enqueue. No network or cluster setup is required. Use it for development and testing, single-node deployments, and services that do not need distribution. Limitations:- No remoting: actors cannot span multiple processes.
- No clustering: no discovery, no relocation, no cluster singletons, no grain distribution.
- Placement options on
SpawnOnandGrainOfare ignored; everything runs locally. - Single point of failure: a process crash stops everything.
Clustered mode
In clustered mode, multiple nodes form a cluster. Actors and grains are location-transparent: you send to a PID or a grain identity, and the framework routes to the correct node. Three components make that work:- Discovery: a pluggable provider (Consul, etcd, Kubernetes, NATS, mDNS, static) that tells the cluster how to find peers. See Service Discovery.
- Cluster registry: a distributed, partitioned key/value store (built on Olric) that records where every actor and grain lives. See Partition Hashing.
- Remoting: the TCP transport that carries messages between nodes. See Remoting.
Enabling cluster mode
Cluster mode has four hard requirements, all checked at start or by configuration validation:- Remoting: clustering needs remoting;
Startfails withclustering needs remoting to be enabledwhenWithRemoteis missing. - A discovery provider, set with
WithDiscovery. - A discovery port and a peers port, set with
WithDiscoveryPortandWithPeersPort. - At least one registered actor kind or grain kind, set with
WithKindsorWithGrains, so remote spawns, activations, and relocations can instantiate workloads on this node.
TLS configured on the actor system with
actor.WithTLS applies to both remoting and the cluster transport. See
Remoting for certificate requirements.Configuration reference
NewClusterConfig returns a configuration with working defaults; only the four requirements above must be provided.
The options below are grouped by concern.
Workload and topology
Registry replication and storage
The cluster registry is partitioned across nodes and replicated per partition. These knobs control durability, consistency, and memory footprint.
The classic read-your-writes guideline (
readQuorum + writeQuorum > replicaCount) is not enforced, and the default
(replicaCount=2 with both quorums at 1) deliberately does not follow it: the registry is rebuildable, single
activation is arbitrated by the partition’s primary owner rather than by quorum overlap, and quorums of 1 keep
registry writes succeeding while a node is down. For a majority configuration, use replicaCount=3 with
writeQuorum=2 and readQuorum=2, accepting higher write latency and fan-out.
Timing
Recommended starting points: small and medium clusters run well with a 1s to 5s balancer interval and 30s to 1m state
sync; large or busy clusters should increase both together (for example 5s balancer with 1m to 2m state sync).
Registry consistency
Actor and grain creation is synchronous with respect to the cluster registry:Spawn, SpawnOn, SpawnSingleton,
and grain activation only return once the registry record is written to the cluster store. As soon as a creation call
succeeds, the actor is resolvable by name (for example via ActorOf) and reachable from any node in the cluster,
with no propagation window to retry around. When the registry write fails, the creation call returns the error and
the actor or grain is stopped, so a failed creation leaves nothing behind.
Placement
Where a new actor or grain lands is controlled at spawn or activation time through placement strategies (round robin, random, local, least load) and node roles. See Placement for the strategies, role constraints, and defaults for both actors and grains.Relocation
When a node leaves, the leader relocates its actors and grains to remaining nodes. Singleton actors move to the leader; others are distributed. Actors can opt out of relocation via spawn options. See Relocation for the full flow, configuration, and relocatability requirements.Leadership
Exactly one node in the cluster acts as the coordinator (leader) at any given time. The leader drives internal responsibilities such as relocation and cluster singleton placement, but its status is also queryable from application code:
Both methods require cluster mode; they return
ErrClusterDisabled when clustering is not enabled.
LeaderChanged event on its
local event stream, alongside NodeJoined and NodeLeft, carrying the new leader’s
address. Like the other topology events, it exists for observability (monitoring, logging, dashboards); leadership
itself is managed entirely by the framework.
LeaderChanged is eventually consistent. It is derived from cluster topology events, so it is published once
per leadership change shortly after the cluster settles, and the node’s initial leadership is seeded silently
rather than announced. Delivery is best-effort and may be missed under heavy event churn. Treat it as a
notification, not a source of truth. When you need the authoritative current leader, call IsLeader(ctx) or
Leader(ctx).See also
- Placement: where actors and grains run
- Service Discovery: discovery provider options
- Partition Hashing: how names map to registry partitions
- Multi Datacenter: spanning clusters across data centers
- Relocation: node departure and workload redistribution
- Remoting: transport configuration and TLS