Slap.Cluster.Strategy.Static (slap_cluster v0.4.0)

Copy Markdown View Source

A fixed assignment of shards to nodes, from configuration: no database, no leases, no failover. A node opens its own shards (and reopens them after a backoff if they fail, like Slap.Cluster.Strategy.Local), and routes to the others by the assignment. If a node is down, its shards are unavailable until it is back.

It suits a Kubernetes StatefulSet (stable names, the platform restarts a failed pod) or any small fixed cluster. Changing the assignment moves shards; do it with the nodes stopped, or accept that two nodes may open a shard for a moment (SlateDB fences one of them).

Options (one of)

  • :nodes - an ordered list of node names; shard n belongs to Enum.at(nodes, rem(n, length(nodes))). For a StatefulSet: nodes: for i <- 0..2, do: :"app@app-#{i}.app-headless.ns.svc".
  • :assignments - %{node => [shard | Range.t()]}, which must cover every shard exactly once.

Plus Local's :backoff_base, :backoff_max and :max_concurrency. Routing goes over distributed Erlang, so the nodes must be connected.