7 The manager enters the room

 

This chapter covers

  • Reviewing the purpose of the manager
  • Designing a naive scheduling algorithm
  • Implementing the manager’s methods for scheduling and updating tasks

In chapters 4, 5, and 6, we implemented the Worker component of Cube, our orchestration system. We focused on the core functionality of the worker in chapter 4, which enabled the worker to start and stop tasks. In chapter 5, we added an API to the worker. This API wrapped the functionality we built in chapter 4 and made it available from standard HTTP clients (e.g., curl). And finally, in chapter 6, we added the ability for our worker to collect metrics about itself and expose those on the same API. With this work, we can run multiple workers, with each worker running multiple tasks.

Now, we’ll move our attention to the Manager component of Cube. As we mentioned in chapter 1, the manager is the brain of an orchestrator. While we have multiple workers, we wouldn’t want to ask the users of our orchestration system to submit their tasks directly to a worker. Why? This would place an unnecessary burden on users, forcing them to be aware of how many workers existed and how many tasks they were already running and to then pick one. Instead, we encapsulate all of that administrative work into the manager. The users submit their tasks to the manager, and it figures out which worker in the system can best handle the task.

7.1 The Cube manager

7.1.1 The components that make up the manager

7.2 The Manager struct

7.3 Implementing the manager’s methods

7.3.1 Implementing the SelectWorker method

7.3.2 Implementing the SendWork method

7.3.3 Implementing the UpdateTasks method

7.3.4 Adding a task to the manager

7.3.5 Creating a manager

7.4 An interlude on failures and resiliency

7.5 Putting it all together

Summary