[erlang-questions] Recommended Application Structure
Matthew Evans
mattevans123@REDACTED
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:
app_foo
|
foo_sup
|
gen_servers
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
Or...
2) A single app with multiple (hierarchical) supervisors (i.e. 1 .app file, all beam files in the same ebin directory):
app_foobar
|
foobar_sup
|
---------------
| |
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).
Thanks
Matt
More information about the erlang-questions
mailing list