I'm working with Elixir but I believe this question applies to Erlang as well.
I'm working on a system which might create dozens of thousands of groups processes of same kind. Each group will have 2 workers and a local supervisor of its own. The question is who will supervise the local supervisors ?
I can imagine two strategies
Does either make sense or is there any other way? Any advice is welcome
"It depends".
"huge list" and "thousands" really are in different realms. Simple iteration is fast on modern machines. Up to high five, low six items I would have no qualms with a system that regularly has to traverse a list this size, and probably over that I wouldn't really care either:
iex(2)> list = Enum.to_list 1..1_000_000; :timer.tc(fn -> Enum.sum list end)
{24497, 500000500000}
(that is 25 ms for the list traversal and some arithmetic - I'm usually happy if a crashed process gets restarted with such small delays)
Of course - at the end of the day you're expected to do your own performance testing, compare the outcomes with the expected local supervisor crash rate, look up your system's requirements, and compare all these figures to come to an answer.
In the meantime, use the simplest thing that can possibly work: a single global supervisor monitoring a flat hierarchy.