Introduction
One of Malla's most powerful features is transparent distributed computing. Services can discover each other across nodes and make remote calls as easily as local ones.
In this tutorial, you'll:
- Set up two Livebook sessions as separate nodes
- Create services that communicate across nodes
- See automatic service discovery in action
- Learn about failover and load balancing
Setup
Malla uses :pg (process groups) for service discovery, which only works between visible nodes. Since Livebook starts its runtimes as hidden nodes, you need to start IEx sessions manually and attach Livebook to them.
Step 1: Start two IEx nodes
Open two terminals from the project directory:
# Terminal 1 (Storage Node)
iex --name storage@127.0.0.1 --cookie malla -S mix
# Terminal 2 (Client Node)
iex --name client@127.0.0.1 --cookie malla -S mix
Step 2: Attach Livebook to each node
Open each notebook in its own Livebook tab. For each tab, go to the Runtime panel, choose Attached node, and enter:
- Storage notebook: Name
storage@127.0.0.1, Cookiemalla - Client notebook: Name
client@127.0.0.1, Cookiemalla
Step 3: Open the notebooks
- Storage Node — start here, creates the StorageService
- Client Node — connects to the storage node and makes remote calls
Run the Storage notebook first, then switch to the Client notebook.
This tutorial only scratches the surface of what Malla offers. Check out the guides and API documentation for the full picture: plugin lifecycle, configuration, reconfiguration, request handling, tracing, and more.