Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to "run out" of Erlang process IDs?

Tags:

erlang

pid

The answer to this question says that Erlang PIDs are actually 28-bit integers, the first 10 of which are the node number (always 0 for the local node), and the next 18 of which are an index into the global process table. So, if my understanding is correct, assuming we're only working on a single node, the maximum number of unique PIDs is 2^18, or about 262,000. Is this then the maximum number of processes that I can spawn on a single Erlang node, over time? If I have a very long-running Erlang node, will the VM immediately crash after I allocate my 2^18+1'th node, or do old, unused PIDs get reused? If so how is that process implemented at the VM level?

like image 545
Ricky Stewart Avatar asked Oct 19 '22 19:10

Ricky Stewart


1 Answers

The answer to the other question seems to refer to an older version of the Erlang runtime, it changed after R9 (R17 is the latest at the moment). According to the implementation the process id uses 28 bits for internal identifiers.

Pids are recycled when the process dies and any monitors has been notified, so 2^28 is the upper limit of the number of simultaneous processes on the node.

The default process limit is 2^18 and can be increased with the +P option to erl, see the erl options documentation.

Note: the documentation says the upper limit is 2^27 processes, that's not consistent with the code.

like image 73
johlo Avatar answered Oct 22 '22 21:10

johlo