GenServer replication (horde) vs Kubernetes StatefulSets

I think most of the elixir developers have considered about this; where to put the GenServer (and its wrappers) on the Kubernetes.

We can use a replicated GenServer across the cluster by adding horde handy.
But It seems the Kubernetes StatefulSets can also be used as a single source of truth.
Or, use a separated Redis node to make GenServer persistent.

I’d like to figure out the de facto structure of Elixir & Kubernetes.

(Please don’t say “you don’t need a Kubernetes most of times.”, because I agree. I think on-premise should be enough most of the Elixir apps. But it’s obvious that harmonizing with other microservices is inevitable to Elixir.)

1 Like

Use both - statefulset for the instances - and horde to balance and supervise - use libcluster to form the cluster. Here’s a strategy you can use to leverage the DNS behaviour of statefulset https://hexdocs.pm/libcluster/Cluster.Strategy.Kubernetes.DNSSRV.html#content - and yes DNS is backed by etcd/raft which is handy.

1 Like