A DynamicSupervisor is a supervisor designed to supervise and manage
many children dynamically.
This is the main purpose of a DynamicSupervisor-- you can read the full proposal on Github
At a high level here are the four main goals outlined in the proposal:
- Simplify the API and usage of both Supervisor modules. Most
of the documentation in the Supervisor module is full of
conditionals: "if the supervisor type is :simple_one_for_one,
it will behave as X, otheriwse as Y." The differences in
behaviour with little surrounding context makes supervisors
hard to learn, understand and use;
- Provide out-of-the-box supervisor sharding for cases where
the supervisor itself may be a scalability concern;
- Provide a built-in registry to avoid developers unecessarily
using dependencies like gproc or incorrect dependencies like
global;
- Implement the GenStage specification
so dynamic supervisors can subscribe to producers and spawn
children dynamically based on demand;