Is it possible to allocate processes to specific cores?

From my understanding, each process you spawn in Elixir is dedicated to a single core which is why it is single-threaded and messages are handled sequentially, etc. So my question is: can I pick which core a process is using? I’ve done some googling and searching here and I can’t seem to find anything about it.

To give a little example of why I’m asking; lets say I have an operation that I’d like to give to a running process to execute. And since one core is not enough to handle this operation, I decide to add an additional process. How can I guarantee that the two processes do not use the same core?

For clarification, I am already very comfortable with libraries for process pooling like poolboy and such. This question is mostly academic and for a deeper understanding of how this works.

Also, on a similar note: is it possible to reserve a core for a certain set of processes? Lets say I want to guarantee their availability while the other processes may be overburdened.

Are you familiar with this?

Process Management Optimizations

when a scheduler thread runs out of work it tries to steal work from another scheduler threads run queue.

Short version: leave it to the BEAM.

As far as I understand it by default one scheduler (i.e. OS thread) is launched per logical core but I suspect that it is responsibility of the OS to keep the scheduler thread on the same core (or not). One under-utilized scheduler will steal work from another busy scheduler.


The Beam Book

Load Balancing

3 Likes

Work stealing is the answer to your question. A process tends to stay on the core to which it is initially assigned, but if work is imbalanced across cores then things get adjusted.

5 Likes