index.tex 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. \section{MAD: Erlang Containers}
  2. \subsection{Purpose}
  3. We were trying to make something minimalistic that fits out \footahref{https://github.com/synrc}{application stack}.
  4. The main idea of mad is to provide clean and simple rebar-like fast dependency manager that
  5. is able to build several types of packages and provides interface of containered deployments
  6. to virtualiezed environments.
  7. \subsection{Several Types of Packaging}
  8. The key feature of mad is ability to create single-file bundled web sites.
  9. This target escript is ready to run on Windows, Linux and Mac.
  10. \subsection{Deployment Options}
  11. As a deploy tool mad is also supposed to launch, start, stop and manage containers, locally or remote.
  12. You can make containers from different type of packages, like making runc container with beam release.
  13. \subsection{OTP Compliant}
  14. Mad supports ERTS boot files generation with systools and erlang application format used by OTP.
  15. This is the main format of application repository. Also boot files are suported on both LING and BEAM.
  16. \subsection{Tiny Size}
  17. And the good part:
  18. \vspace{1\baselineskip}
  19. \begin{lstlisting}
  20. Sources Binary
  21. mad 967 LOC 52 KB
  22. rebar 7717 LOC 181 KB
  23. \end{lstlisting}
  24. \vspace{1\baselineskip}
  25. \subsection{History}
  26. We came to conclusion that no matter how perfect your libraries are,
  27. the comfort and ease come mostly from developing tools.
  28. Everything got started when \footahref{https://github.com/proger}{Vladimir~Kirillov} decided to
  29. replace Rusty's sync beam reloader. As you know sync uses
  30. filesystem polling which is neither energy-efficient nor elegant. Also
  31. sync is only able to recompile separate modules while
  32. common use-case in N2O is to recompile DTL templates
  33. and LESS/SCSS stylesheets. That is why we need to recompile
  34. the whole project. That's the story how \footahref{https://github.com/synrc/active}{active} emerged.
  35. Under the hood active is a client subscriber
  36. of \footahref{https://github.com/synrc/fs}{fs} library, native filesystem listener for Linux, Windows and Mac.
  37. De-facto standard in Erlang world is rebar.
  38. We love rebar interface despite its implementation.
  39. First we plugged rebar into active and then decided to drop its support,
  40. it was slow, especially in cold recompilation.
  41. It was designed to be a stand-alone tool, so it has some
  42. glitches while using as embedded library.
  43. Later we switched to Makefile-based build tool \footahref{https://github.com/synrc/otp.mk}{otp.mk}.
  44. The idea to build rebar replacement was up in the air for a long time.
  45. The best minimal approach was picked up by \footahref{https://github.com/s1n4}{Sina~Samavati},
  46. who implemented the first prototype called 'mad'. Initially mad
  47. was able to compile DTL templates, YECC files, escript (like
  48. bundled in gproc), also it had support for caching with side-effects.
  49. In a month I forked mad and took over the development under the same name.
  50. \vspace{1\baselineskip}
  51. \begin{lstlisting}[caption=Example of building N2O sample]
  52. Cold Hot
  53. rebar get-deps compile 53.156s 4.714s
  54. mad deps compile 54.097s 0.899s
  55. \end{lstlisting}
  56. \vspace{1\baselineskip}
  57. \vspace{1\baselineskip}
  58. \begin{lstlisting}[caption=Example of building Cowboy]
  59. Hot
  60. make (erlang.mk) 2.588s
  61. mad compile 2.521s
  62. \end{lstlisting}
  63. \vspace{1\baselineskip}