liveBook · Manning

Node

As explained in Build and Orchestrator in Go (From Scratch)

A node is a machine-representing object in a cluster that exposes identity, network location, capacity, and allocation information for scheduling.

A node represents a physical or virtual machine in a cluster. It gives the manager a concrete object for addressing machines, understanding their capacity, tracking allocations, and making scheduling decisions. Workers run on nodes, while the manager is also modeled as a node. section 2.5

A node records the information needed to place and monitor tasks:

  • Identity and location: Name identifies the machine, while Ip lets the manager send tasks to it. section 2.5
  • Allocation: MemoryAllocated and DiskAllocated track resource consumption as tasks run. section 2.5

The node also owns communication with its machine endpoint. GetStats builds the node's /stats URL, retries transient HTTP failures, checks the response, and decodes JSON into runtime statistics. Moving this responsibility into Node keeps scheduler code focused on scheduling rather than HTTP details. section 10.9

Polling a worker node

A scheduler can call node.GetStats twice, with a delay between calls, and use the returned statistics to calculate CPU usage. If the worker is rebooting or the network is temporarily unavailable, HTTPWithRetry makes several attempts before reporting failure.

How Build and Orchestrator in Go (From Scratch) covers it

How deep it goes
Defines Go fields and implements stats retrieval with retries, response checks, and JSON decoding.
Examples
Uses node-1, machine capacity fields, the /stats endpoint, HTTP retries, and repeated polling for CPU usage.
What it assumes
Assumes a mental model containing workers, managers, schedulers, and tasks, while introducing the node as the workers' physical aspect.
What you can do after
Build it from scratch as a Go struct and operate it through resilient statistics retrieval for scheduler decisions.
How it connects
Connects cluster machines with workers, managers, schedulers, tasks, resource allocation, and runtime statistics.

Also explained in

Compare how 19 books explain node →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build and Orchestrator in Go (From Scratch). The section links point to the parts of the book it draws on.