Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the maximum number of child processes a supervisor can supervise?

Is there a maximum number of child processes a supervisor process can supervise? I'm coming from Elixir, but I imagine the limit (if there is one) would be inherited directly from Erlang.

like image 419
Ashton Wiersdorf Avatar asked Jan 25 '23 23:01

Ashton Wiersdorf


2 Answers

I'm no expert but found this in the erlang docs:

10.2 System limits

The Erlang language specification puts no limits on number of processes, length of atoms etc., but for performance and memory saving reasons, there will always be limits in a practical implementation of the Erlang language and execution environment.

Processes

The maximum number of simultaneously alive Erlang processes is by default 32768. This limit can be raised up to at most 268435456 processes at startup (see documentation of the system flag +P in the erl(1) documentation). The maximum limit of 268435456 processes will at least on a 32-bit architecture be impossible to reach due to memory shortage.

This doesn't mention gen_server but it puts an upper bound on the number of concurrent processes in a default erlang system: 32768. So perhaps the answer to your question is simply 32768 - 1. :) And you can use the +P switch to increase that number.

like image 117
zwippie Avatar answered Jan 28 '23 23:01

zwippie


gen_server itself doesn't impose any particular restriction on the number of processes it can manage (apart from system limits) but if you add large enough amounts of children, you will (of course) eventually run into performance issues. gen_server tries to be efficient regarding large number of children by e.g. not storing them in a linear list.

(If you really need to know the exact answer, you're probably designing your system in a suboptimal way, I would say.)

like image 45
JesperE Avatar answered Jan 28 '23 22:01

JesperE