Chapter 4. Creating a New Framework for Mesos
A Mesos framework is the conceptual aggregation of a distributed system. But what does that mean to us, as framework developers? How can we actually understand how the structure of the code we write maps onto the Mesos cluster? Let’s review the Mesos architecture, and learn some common patterns in framework design.
Instead of trying to understand everything about Mesos architecture all at once, we’ll look at the simplest case: a framework that only has a scheduler, and no custom executor. This type of framework could spin up workers to process requests coming in on a queue, or it could manage a pool of services.
The Scheduler
The scheduler is the component that interacts directly with the leading Mesos master. A scheduler has four responsibilities:
-
Launch tasks on the received offers.
-
Handle status updates from those tasks, particularly to respond to task failures and crashes.
-
Persist state and manage failovers in order to be highly available.
-
Interact with clients, users, or other systems (since no system runs in a vacuum!).
Some of these responsibilities are implemented purely by interacting with the Mesos API; others must be implemented using the language of choice’s platform. For instance, launching tasks and handling status updates are implemented entirely by Mesos callbacks and API requests. On the other hand, it’s up to you to start a web server (such as Jetty on Java or Flask on Python) to allow clients to interact ...