xrodriguez

xrodriguez

Project structure - Umbrella or Poncho approaches?

Hi everyone!
I’ve been in Elixir for 3 months and I want to develop a platform which has to support a lot of concurrent users (+50.000, by the moment). I’ve learned a lot about the language and some advises that the community shares constantly. But my main question appears when I think about the project structure. This platform will have a lot of modules, maybe about 10 (and not little ones, so perhaps I should split some of them), and some of them should use Phoenix (but not all of them).
I’ve searched about Umbrella structure and I think that I know more or less how it works. But also I’ve found that a lot of people does not recommend it when talking about production. Then I searched a little bit more and I found articles about the Poncho mindset, which isolates completely and works using the paths / repositories dependencies.
I’ve seen some topics talking about this, but they don’t really have a solid conclusion (there are still some Umbrella followers).
So my question would be: what is the best project structure when we talk about a platform of this size (thinking in future scalability), and if a Poncho structure would make it slower or faster?

Thanks a lot!!

Most Liked

LostKobrakai

LostKobrakai

I feel like arguing about plain mix projects and poncho or umbrella style projects is the wrong level.

In elixir you basically have two kinds of “structure”. Structure of code – which should be handled by modules and folders in your source code – and structure of runtime concerns, like dependencies or being able to run parts of your application independently from others – which is what drives how you set up supervision trees or multiple otp applications.

What’s often criticized with umbrellas is using the latter solution (otp applications) for the first reasoning. Don’t just put code in multiple otp applications if those parts of code are not meant to be run in isolation. A single otp application is just fine for that.

On the other hand if you intend to split up your application at runtime e.g. over multiple nodes then go for properly devided otp applications.

As for poncho vs. umbrella. Poncho style project setups are way more explicit especially when it comes to configuration. With umbrellas people often seem to have problems with the fact that config (just like dependencies) are set for the whole umbrella. With elixir 1.9 this is even enforced by the generators, which no longer generate application level config in umbrellas. For the nerves people where configuration is even more complex because of target machine differences the solution was to just not use umbrellas. Personally I feel like both are usable and you need to find what style of thinking about/working with your application suits you more. Either “one piece at a time” (poncho) or “the whole as the sum of all parts” (umbrella).

11
Post #2
hauleth

hauleth

IMHO there is almost no difference between these two approaches since 1.9 (and earlier the only difference in reality was handling the configuration). Right now I would go with Umbrellas even more, as it provides what I want almost directly OOTB and with Poncho I need to manage everything by myself or use external tools.

LostKobrakai

LostKobrakai

If you have incompatibilities you’ll have them with the poncho style project as well. At runtime things are run exactly the same. In umbrellas you’re just forced to spot those issues as you’ll always maintain just one set of configs / run apps together more often, while for poncho applications those things might be discovered later e.g. when switching to a “higher level” application. Both have their place though and it’s a tradeoff between more flexibility and tighter control.

Personally I feel like poncho style applications make the most sense in loosely coupled projects like nerves. There might be an application for talking to a special sensor and it just needs to be included to be called from elsewhere, but there are no other dependencies between applications. If things are more coupled, but e.g. in separate apps to split load or failures predictable between different nodes I’d rather opt for an umbrella.

Where Next?

Popular in Questions Top

aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
earth10
Hi, I’m just starting to build a side-project with Elixir and Phoenix and doing some basic test with Elixir alone. What strikes me is th...
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
dotdotdotPaul
Okay, I’m having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I’m sure I’...
New

Other popular topics Top

9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 43622 214
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 52341 488
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New

Latest on Elixir Forum

We're in Beta

About us Mission Statement