Skip to main content

How it works: the parts and their names

This page explains the words the rest of the documentation uses. Read it once and the other pages are easier to follow.

What a runner does in Nornir​

When you call nr.run(task=my_task), Nornir has a list of hosts and one task. The runner is the part of Nornir that decides where and when the task runs for each host.

  • Nornir's ThreadedRunner runs the task in threads, inside the Python process of your script.
  • The ray runner of nornir-ray sends each host's task to another process, which can be on another machine.

You select a runner in the configuration or in code. Your tasks do not select it.

The five parts​

NameWhat it is
HostOne entry of the Nornir inventory, usually a network device
DriverThe Python process that runs your Nornir script, and the machine it runs on
Ray clusterA group of machines that run Ray and accept work from the driver. A cluster can be one machine
NodeOne machine of the cluster
WorkerA process on a node that runs tasks for hosts. Each node runs a fixed number of workers

Ray is the software that starts the worker processes on the nodes and carries the messages between the driver and the workers. You do not write Ray code to use the runner.

How many hosts run at the same time​

Two options set the capacity:

  • workers_per_node: the number of worker processes on each node. The default is 4.
  • hosts_per_worker: the number of hosts that one worker runs at the same time. The default is 16.

One node therefore runs 4 × 16 = 64 hosts at the same time with the defaults. A cluster of three nodes runs 192. The other hosts wait for a free place on their worker.

Each host has its own worker​

The runner gives each host to one worker, and gives the same host to the same worker at every run, as long as the set of workers does not change. This rule is the reason device sessions can stay open between runs. Sessions stay open between runs explains it.

What runs where​

On the driverOn a worker
Your scriptYour task function, once for each host of that worker
The inventory and the filtering of hostsThe connection to the device
The deadlines (timeout, per_host_timeout)The device session, kept between runs
The processors and the resultsA copy of the host's inventory data

Next: what happens during one run.