Skip to content

Clustering for your Elixir / Phoenix App

Elixir apps support clustering out of the box. Clustering can bring many advantages like:

  • Distributed caching
  • Fault tolerance
  • Distributing workload across cluster

libcluster

If you wish to use clustering in your application please make sure you have :libcluster installed as a dependency. We also have a hex package that will make clustering in your application easy.

mix.exs
def deps do
[
{:libcluster, "~> 3.0"},
{:libcluster_uplink, "~> 0.2.0"}
]
end

Then simply add the following to your runtime config.

config/runtime.exs
config :libcluster,
topologies: [
example: [
strategy: Cluster.Strategy.Uplink,
config: [
app_name: "example-app"
]
]
]

This will enable automated clustering for your application inside the OpsMaru provisioned cluster.