Understanding supervisor

Hi all,

I need help on understanding supervisor role in “ordinary” web architecture.

I’m thinking the data flow will be like the following (notice the plurals):

client -> Load Balancer (LB) -> elixir apps -> workers


client -> LB -> elixir apps -> supervisor -> workers


client -> LB -> elixir apps -> LB -> workers


client -> LB -> elixir apps -> message queue -> workers

The questions are:

  1. Where the supervisor should resides?
  2. Does LB and MQ diminish the role of a supervisor?

Or I might be wrong at all as thinking OTP supervisor as infrastructure layer supervisor.

The supervisor doesn’t do anything to your request. It just sits there and restart crashed processes.

so, supervisor doesn’t manages child node process at all?

Supervision trees is how you impose structure to your Erlang programs. They start with a simple concept, a supervisor, whose only job is to start processes, look at them, and restart them when they fail. By the way, supervisor are one of the core components of ‘OTP’, the general development framework used in the name ‘Erlang/OTP’.


Usually it only managed static and longrunning processes, not such that are only spawned to handle a single request/workunit/connection or similar.

yes, but that article doesn’t mention supervisor’s relationship with “non OTP system” like the LB and MQ.

Supervisor is an OTP concept. The load balancing between nodes is the responsibility of the BEAM. RabbitMQ is an OTP application (unless you are talking about the BEAM process mailboxes - the mailbox is an integral part of any BEAM process while the BEAM handles the details of message routing between BEAM processes).

Is your question about Erlang supervisors, or the abstract idea of a supervisor in general?

Assuming the first, in your example, supervisors are internal to the Elixir app (and the message queue, if you’re using rabbitmq). They have nothing to do with load balancing, etc. It’s just a way of organizing work within an OS process. It’s not an infra-level concept.

The BEAM spreads processes on schedulers within a single node. It doesn’t load balance between nodes.

RIght - got carried away there - the BEAM distributes the processes across the all the cores available to the node.