# Distributed Services with Malla

## 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:

1. Set up two Livebook sessions as separate nodes
2. Create services that communicate across nodes
3. See automatic service discovery in action
4. 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:

```bash
# 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`, Cookie `malla`
* **Client notebook**: Name `client@127.0.0.1`, Cookie `malla`

### Step 3: Open the notebooks

1. **[Storage Node](livebook/distributed_storage.livemd)** — start here, creates the StorageService
2. **[Client Node](livebook/distributed_client.livemd)** — 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](introduction.html) and API documentation for the full picture: plugin lifecycle, configuration, reconfiguration, request handling, tracing, and more.
