Malla

Malla is a framework for developing distributed services in Elixir. It simplifies distributed service development through a plugin-based architecture with compile-time callback chaining, automatic service discovery across nodes, and minimal "magic" to keep systems understandable.

Why Malla?

Developing distributed services can be challenging. Malla simplifies the process by handling much of the boilerplate while giving you the flexibility to implement custom behaviors and use any libraries without enforced constraints.

Malla is built on years of production experience running critical systems. This real-world battle testing has shaped its design to prioritize what matters most: simplicity, safe evolution, and practical flexibility.

Not Just for Distributed Systems

While Malla excels at distributed computing, you don't need a cluster to benefit from it. On a single node, Malla gives you a plugin-based service architecture with compile-time callback chaining, runtime plugin management (add, remove, or reconfigure plugins without restarting), service lifecycle control, and built-in observability. If you need structured, evolvable services with runtime flexibility — even on a single BEAM instance — Malla has you covered. Distribution is there when you need it, but the service-management and runtime capabilities stand on their own.

Key Principles

Core Features

Optional Included Utilities

Installation

Prerequisites

Adding Malla to Your Project

Add malla to your list of dependencies in mix.exs:

def deps do
  [
    {:malla, "~> 0.1.0"}
  ]
end

Then run mix deps.get to install the dependency.

Quick Start

  1. Define a service with use Malla.Service, global: true to make it discoverable across the cluster.

    defmodule MyService do
      use Malla.Service, 
        global: true
        
      # A callback that can be called remotely
      defcb fun1(a) do
        {:ok, %{you_said: a}}
      end
    end
  2. Start the service on one node.

    iex --sname node1 --cookie my_secret -S mix
    iex(node1@hostname)> MyService.start_link()
  3. Connect from another node and call the service. Malla handles the remote call transparently.

    iex --sname node2 --cookie my_secret -S mix
    iex(node2@hostname)> Node.connect(:"node1@hostname")
    true
    iex(node2@hostname)> MyService.fun1("hello from node2")
    {:ok, %{you_said: "hello from node2"}}

Interactive Tutorials

The best way to learn Malla is through our interactive LiveBook tutorials:

Open these tutorials in LiveBook for an interactive, hands-on learning experience.

Architecture Overview

Plugin System

Malla's architecture centers on a sophisticated plugin system where behavior is composed through callback chains resolved at compile time:

Your Service Module (Top of chain - highest priority)
    ↓ Custom business logic
    ↓ Can override any plugin behavior
    ↓
Your Plugins (Middleware layer)
    ↓ Authentication, logging, caching
    ↓ Can modify, observe, or block calls
    ↓
Malla.Plugins.Base (Bottom of chain - default behavior)
    • Always present
    • Provides fallback implementations

Key characteristics:

Distributed Services

Services marked as global: true automatically:

Use Cases

Malla is ideal for:

Documentation

For a complete understanding of Malla's features, please see the full documentation in the guides directory.

The guides provide a comprehensive overview of:

AI-Assisted Development

Malla ships with instruction files that help AI coding assistants (Claude Code, OpenAI Codex, Cursor, GitHub Copilot, etc.) generate correct Malla services and plugins.

If you use Malla as a dependency, add this line to your project's AI instruction file to teach your assistant about Malla patterns:

Tool File Add this line
Claude Code CLAUDE.md@deps/malla/priv/ai/AGENTS.md
OpenAI Codex AGENTS.md@deps/malla/priv/ai/AGENTS.md
Cursor .cursor/rules/malla.md Copy the contents of deps/malla/priv/ai/AGENTS.md
Others Your tool's instruction file Reference or copy deps/malla/priv/ai/AGENTS.md

If you contribute to Malla itself, the AGENTS.md and CLAUDE.md files at the project root are automatically picked up by most AI coding tools.

Contributing

Contributions are welcome! Please feel free to open an issue or submit a pull request.

License

Malla is released under the Apache 2.0 License. See the LICENSE file for more details.