[erlang-questions] Recommended Application Structure

Matthew Evans <>
Sun Oct 23 19:59:33 CEST 2011

Hi List,

I've often wondered what is the correct (as in idiomatic Erlang) way to structure an sufficiently complex service in Erlang?

Obviously a simple service would be a single application, with a supervisor hierarchy something like:


Let's suppose you have a complex service to deploy (that does related, but functionally separate tasks), what is normal: 

1) Separating the complexity as multiple apps (i.e. 2 .app files and beam files in separate ebin directories):

app_foo               app_bar

   |                     |

foo_sup               bar_sup

   |                     |

gen_servers           gen_servers


2) A single app with multiple (hierarchical) supervisors (i.e. 1 .app file, all beam files in the same ebin directory):

   |             |
foo_sup       bar_sup
   |             |
  foo's         bar's   
gen_servers  gen_servers

Seems like the preference is towards example 2; but to me this means that you can't easily decompose and separate functionality apart. It also means that messaging can jump across supervisors making for somewhat messy interfaces (plus having to cross supervise/link gen_servers that are separated by different supervisors).



More information about the erlang-questions mailing list