We’ll look at how the BEAM manages different system resources, and we’ll discuss the needs of real-time applications versus more traditional ones.

Two primary resources are required to run applications:

  1. CPU
  2. Memory

We’ll see how the BEAM uses these resources and how we can build our application to utilize our system’s available resources best. The BEAM is a solid virtual machine to run applications on top of, but we need to be mindful of how it schedules work and uses memory when deploying high-volume applications.

We’ll start by looking at how the BEAM performs work. We’ll see how the scheduler works, and we’ll look at how applications can effectively utilize a system’s CPU. After that, we’ll go over how the BEAM allocates and garbage collects memory. Finally, we’ll see a tool that allows us to inspect how a production system uses its resources.

Let’s jump in—we’ll start with how an Elixir process performs work.

Getting comfortable with Elixir’s scheduler

The most crucial role of any software is getting work done. It’s easy to take this for granted—we write code, and it runs on a CPU. However, how work gets done can make or break our experience with a language. Some languages require us to be very explicit about everything—we get full control, but we can quickly encounter problems. Other languages take away some control to provide us with ease of use and stability. Elixir falls into the camp of ease and stability, but its virtual machine has a scheduler with well-suited properties for soft real-time applications.

Get hands-on with 1200+ tech skills courses.