Designing Process Trees and Supervision in Elixir Applications

59
clicks
Designing Process Trees and Supervision in Elixir Applications

Source: reddit.com

Type: Discussion

Sectional343 is building an Elixir application with several subsystems such as 'Quiz' and 'Leaderboard', which are both trees of processes. They want to start these subsystems as part of their main application using a top-level supervisor. Currently, they are using a GenServer to start subsystem children within its init() method, but are unsure if this approach is correct or if using the 'use Application' abstraction might be better. A commenter, BunnyLushington, suggests avoiding organizing the process tree by business functionality, not nesting applications, and starting processes with a supervisor instead of a GenServer. They also provide alternatives such as using an Agent for the leaderboard and DynamicSupervisor for quiz sessions. BunnyLushington stresses the importance of simplicity and using processes where beneficial for concurrency, state, and restart semantics.

© HashMerge 2024