Are Supervisor processes GenServer processes?

Are Supervisors themselves GenServers? I am trying to have a Supervisor starting multiple worker processes, and the worker processes will periodically send its progress back to the Supervisor, and the Supervisor will aggregate the progress, probably do some more processing and send it to another process…so on and so forth. But I am confused by the fact that Supervisor’s only callback function is init (args), which will clash with GenServer’s init method I am trying to use the Supervisor as a GenServer process.

Is this even the right way to think of this? Or is supervision the only job of a Supervisor, and I should have a separate “aggregator” GenServer instances that is also supervised by this Supervisor which aggregates the data from the workers?



Yes, Supervisors are GenServers, and no, you don’t want to use them for business logic. You’ll be better having separate “aggregator” GenServers for your needs as you’ve already suspected. Supervisors should be extremely lightweight with low risk of having their own bugs, because their job is to restart other processes.


That general pattern should be:

Supervisor (main)
 | GenServer (manager)
 | Supervisor (of workers, this might even be a simple_one_for_one)
   | GenServer (worker)
   | GenServer (worker)
   | ...