主管可以监督的最大子进程数是多少?

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

一个监管进程可以监管的子进程数量是否有上限?我来自 Elixir,但我想限制(如果有的话)会直接从 Erlang 继承。

我不是专家,但在 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.

这里没有提到 gen_server,但它对默认 erlang 系统中的并发进程数设置了上限:32768。所以也许你的问题的答案很简单 32768 - 1。 :) 您可以使用 +P switch 来增加该数字。

gen_server 本身并没有对其可以管理的进程数量施加任何特定限制(除了系统限制),但是如果你添加足够大的 children,你将(的当然)最终 运行 进入性能问题。 gen_server 试图通过例如大量 children 来提高效率不将它们存储在线性列表中。

(如果你真的需要知道确切的答案,我会说你可能正在以次优的方式设计你的系统。)