liveBook · Manning

Concurrency model

As explained in Elixir in Action, Third Edition

A concurrency model is the set of abstractions and rules a programming language uses to represent and coordinate simultaneous computation.

A concurrency model defines how a language represents simultaneous computation and coordinates independent work. In Erlang and BEAM, it is designed around availability: lengthy tasks should not block unrelated requests, background jobs, or live software updates. section 1.1.1 section 5.1

BEAM processes are lightweight concurrent threads of execution managed by the virtual machine rather than directly by the operating system. They may run in parallel when CPU cores are available, while isolation limits the effect of failures. section 5.1

The model connects concurrency to production behavior:

  • Run work in separate processes so one lengthy request does not cause request queues to grow indefinitely or make the system unresponsive. section 5.1
  • Isolate processes so an unhandled exception can be localized instead of corrupting unrelated tasks or crashing the entire server. section 5.1
  • Schedule many lightweight processes across VM-managed schedulers, with each process receiving an execution time slot before preemption. section 5.1

Fine-grained game concurrency

An online multiplayer game can use at least one process per participating player and per game session. This granularity improves responsiveness, enables vertical scalability, and increases fault tolerance more directly than assigning many activities to a small number of microservice instances. section 1.1.5

Figure 5.1 BEAM as a single OS process, using a few threads to schedule a large number of processes
CH05_F01_Juric3

Visualize BEAM as one operating-system process containing a few scheduler threads that coordinate a much larger population of VM-managed processes. section 5.1

How Elixir in Action, Third Edition covers it

How deep it goes
Explains process isolation, parallelism, VM scheduling, preemption, and operating-system structure, while stopping short of detailed messaging mechanics.
Examples
Uses request handlers, background jobs, live updates, and per-player or per-session processes in an online multiplayer game.
What it assumes
Assumes familiarity with servers and operating-system processes while introducing BEAM processes, schedulers, and VM-managed execution.
What you can do after
Evaluate/understand how BEAM processes distribute work and contain failures in highly concurrent server systems.
How it connects
Connects processes with schedulers, parallelism, scalability, fault tolerance, availability, and microservices.

Also explained in

Compare how 2 books explain concurrency model →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Elixir in Action, Third Edition. The section links point to the parts of the book it draws on.