Chapter 21
Tasks and Agents

This part of the book is about processes and process distribution. So far we’ve covered two extremes. In the first chapters we looked at the spawn primitive, along with message sending and receiving and multinode operations. We then looked at OTP, the 800-pound gorilla of process architecture.

Sometimes, though, we want something in the middle. We want to be able to run simple processes, either for background processing or for maintaining state. But we don’t want to be bothered with the low-level details of spawn, send, and receive, and we really don’t need the extra control that writing our own GenServer gives us.

Enter tasks and agents, two simple-to-use Elixir abstractions. These use OTP’s features but insulate us from these details.