Erlang / Erlang Basics Interview questions
Explain the internal working of the BEAM scheduler?
The BEAM typically runs one scheduler thread per CPU core, and each scheduler maintains its own run queue of processes ready to execute. Rather than relying on OS-level time slicing, the BEAM preempts processes based on a reduction count — roughly one reduction per function call/operation — giving each process a budget (around 2000 reductions) before it's paused and put back at the end of the run queue.
flowchart LR
A[Run queue: Process A, B, C] --> B[Scheduler picks Process A]
B --> C{Reduction budget exhausted or process waits?}
C -->|Yes| D[Process A suspended, requeued]
C -->|No, finished naturally| E[Process A removed from queue]
D --> A
This makes scheduling fair and predictable regardless of what an individual process does — a process stuck in a tight loop can't starve others, since it gets preempted at the reduction boundary just like everyone else. Schedulers also periodically rebalance work across cores via work stealing, so a scheduler that runs out of ready processes can pull some from a busier neighbor's queue instead of sitting idle.
More Related questions...