MAD: Erlang Containers


We were trying to make something minimalistic that fits out application stack. The main idea of mad is to provide clean and simple rebar-like fast dependency manager that is able to build several types of packages and provides interface of containered deployments to virtualiezed environments.

Several Types of Packaging

The key feature of mad is ability to create single-file bundled web sites. This target escript is ready to run on Windows, Linux and Mac.

Deployment Options

As a deploy tool mad is also supposed to launch, start, stop and manage containers, locally or remote. You can make containers from different type of packages, like making runc container with beam release.

OTP Compliant

Mad supports ERTS boot files generation with systools and erlang application format used by OTP. This is the main format of application repository. Also boot files are suported on both LING and BEAM.

Tiny Size

And the good part:

Sources Binary mad 967 LOC 52 KB rebar 7717 LOC 181 KB


We came to conclusion that no matter how perfect your libraries are, the comfort and ease come mostly from developing tools. Everything got started when Vladimir Kirillov decided to replace Rusty’s sync beam reloader. As you know sync uses filesystem polling which is neither energy-efficient nor elegant. Also sync is only able to recompile separate modules while common use-case in N2O is to recompile DTL templates and LESS/SCSS stylesheets. That is why we need to recompile the whole project. That’s the story how active emerged. Under the hood active is a client subscriber of fs library, native filesystem listener for Linux, Windows and Mac.

De-facto standard in Erlang world is rebar. We love rebar interface despite its implementation. First we plugged rebar into active and then decided to drop its support, it was slow, especially in cold recompilation. It was designed to be a stand-alone tool, so it has some glitches while using as embedded library. Later we switched to Makefile-based build tool

The idea to build rebar replacement was up in the air for a long time. The best minimal approach was picked up by Sina Samavati, who implemented the first prototype called ’mad’. Initially mad was able to compile DTL templates, YECC files, escript (like bundled in gproc), also it had support for caching with side-effects. In a month I forked mad and took over the development under the same name.

Listing 1: Example of building N2O sample

Cold Hot rebar get-deps compile 53.156s 4.714s mad deps compile 54.097s 0.899s
Listing 2: Example of building Cowboy

Hot make ( 2.588s mad compile 2.521s

About MAD

At the beginning, Mad was supposed to be only a Rebar-compatible dependency manager, after a while, I realized compiling applications as fast as possible with it could be a fascinating work as well.
Sina Samavati, Original MAD Author


Events | Privacy Policy | Feedback | Brandbook
Copyright © 2005–2018 Synrc Research Center s.r.o.