I recently installed RabbitMQ on a Debian 11 server and noticed that the vast majority of threads now belong to the same process - beam.smp. From what I found on the Internet, this process is Erlang's runtime or VM, a dependancy of RabbitMQ. The output of ps
indicates that it is a single process with 1200 threads.
$ ps -e | grep beam.smp | wc -l
1
$ ps -eLF | grep beam.smp | wc -l
1200
CPU usage is very low, so all these threads must be sleeping. However, I find it very weird for a single process to have that many threads.
Is this normal or is it a sign of misconfiguration? Or could it be a bug? It doesn't seem to cause any immediate issues but could it lead to problems at a later time?
Normally I would provide the contents of a configuration file but in this case I can't find the configuration file that is responsible for beam.smp.
Thousands of threads is easy with Erlang. Likely you can use that tuning as is, especially if resource use is manageable.
BEAM is the reference Erlang VM which is what RabbitMQ is built on. Erlang has native concurrency, with lightweight processes doing message passing. So lightweight RabbitMQ docs discuss 2 million processes for very large numbers of concurrent connections. Other resource limits constrain how large the system can get in practice.
On Linux, threads happens to be the implementation to make the runtime go. Which means many tasks that share the same group ID, and they appear as the same process ID (different meaning from Erlang processes).
On POSIX systems very many threads is not common in applications. Appreciate that the PID is the only way to count tasks. For example, with SMP, one many-threaded PID can exceed 100% CPU.