Using libcluster with the libcluster_hop strategy, you can easily create a clustered Elixir application on Hop. All nodes (containers) will be connected to each other.

Demo

You can see a live version of this demo already deployed here

We have created a demo application that you can deploy to Hop to see how it works. It’s a simple Elixir application that uses the libcluster_hop strategy and exposes a simple HTTP API which lets you see the nodes connected to each other.

Deploying the demo

  1. Fork elixir_cluster on GitHub.
  2. Obtain a project token for your Hop project. libcluster uses this to fetch the list of nodes in the cluster using the Hop API. Make sure to select the Manage Deployments permission when creating it.
  3. Create a new Hop deployment on the Console and select the GitHub repository you just forked.
  4. Set the following environment variables before deploying:
NameValue
HOP_TOKENThe project token you obtained in step 2
RELEASE_DISTRIBUTIONnone
  1. Hit Deploy and wait for the build to finish.
  2. To expose your application to the web, create a Gateway and point it to port 8080.

That’s it! You’re now able to scale your Elixir cluster and containers will automatically discover and connect to each other.