Jul 16, 2026 · 12563 words · 59 min read

Scaling and Reliability#

The network team planned a big firmware upgrade for three weeks: 800 campus switches (from three different vendors) in a maintenance window from 00:00 to 06:00.

They relied on a well-tested Network Automation Platform (NAP), and the team had run similar upgrades through it before (smaller ones, though). To speed it up, they configured 48 workers to run the upgrade jobs in parallel.

As planned, at 00:00, the automation kicked in. By 03:20, 47 of the 48 workers had completed: 787 switches upgraded successfully. Almost ready to go to bed. However, one worker was still running… In the Orchestrator, it showed as active, and no error was raised, so there was still hope. But the problem was subtle. One of the devices was not responding to management commands, but it had not explicitly rejected the connection either. Thus, the worker was waiting for the connection to succeed or fail.

One device was blocking a whole worker, and the other devices in that worker were queued, waiting to be tackled, without any visibility for the network team. The worker’s queue depth was not tracked, and there was no alert (waiting for some devices to complete was not unusual).

When the maintenance window expired at 06:00, the job was canceled, and twelve devices still had the previous firmware version, without even being attempted, because one misbehaving device had blocked their worker. The next day was troubleshooting day. The team tried to establish what was going on with the faulty device and, more importantly, why the other non-upgraded devices also failed without sharing any characteristics with it. There was no clear understanding that they shared the same worker, and because the failure was distributed, solving it required correlating data from different data sources that had never been queried together.

Everything was running: the NAP workflows, the Internal Developer Platform (IDP) workers, and the queue. What was missing was the reliability engineering practice that this chapter brings in: how to handle degraded situations smoothly. When a worker gets stuck, reassign the queued jobs to another worker. If reassignment is not possible, alert when the queue size does not change, and correlate these issues to help the diagnosis.

In Chapter 11, I presented an ideal NAP under normal conditions. Here, I want you to consider what could go wrong under real conditions (many things, to be honest): partial failures, concurrent load, slow dependencies, and the many ambiguous errors that distributed systems produce.

The chapter is organized under three main topics:

  • Scale asks how the NAP handles growing workloads: more devices and concurrent workflows.
  • Reliability asks how the NAP behaves when things go wrong.
  • Operational excellence is how you know the NAP keeps working.

These three concerns compound together. A NAP that scales well but fails unpredictably is still an issue. And connecting with Chapter 2, to build trust, you have to be ready for (almost) everything.

Human approval gates and the automation track record that connects NAP evidence to the organizational trust model are addressed in Chapter 13 and Chapter 14 respectively, where they belong alongside the governance and cultural shift material.

The foundations come first: what scale means, and three decisions that shape every component as it grows.

Foundations of Scale#

Start with why these patterns are necessary. A 200-device network with one engineer does not need worker sharding or data-layer partitioning. Sequential processing is slow but good enough. The cost of distributed complexity at small scale is higher than the benefit it provides: these patterns are necessary at scale (do not solve complexity in advance). But what does scale mean?

These are scale thresholds at which naive approaches break down:

  • At a few hundred devices, sequential processing works. A single worker running through a device list takes minutes to hours depending on the operation. Parallelism helps but is not essential.

  • At a few thousand devices, sequential processing becomes unacceptable for time-sensitive operations. An overnight firmware upgrade window may not be large enough for a sequential run. Worker parallelism becomes necessary, which introduces the coordination and failure-handling problems that this chapter addresses.

  • At tens of thousands of devices, data retrieval becomes a bottleneck independent of execution parallelism. A full inventory query, all devices, interfaces, cables, and connections, can take many minutes against a single database at this scale. The execution workers sit idle waiting for the inventory query that their job requires to even start. Sharding the data layer, or adopting event-driven data updates, is required at this scale for correct operation within any reasonable time bound.

These thresholds are not precise; they depend on many variables: the Source of Truth implementation, the device Application Programming Interface (API) response times, the network topology, or the nature of the workflows being run. The campus running example, 800 switches across three vendors, sits at the second threshold. Sequential processing is too slow for time-sensitive bulk operations, as the firmware upgrade in the opening story shows, so worker parallelism is necessary. The coordination and failure-handling patterns in the Scaling Patterns and Reliability Engineering sections apply directly.

Data-layer sharding and event-driven Source of Truth consumption are for the third threshold: they are worth understanding, but the campus NAP does not require them. Design decisions that feel optional at small scale become mandatory at large scale. Teams that defer them retrofit distributed architecture onto a NAP not designed for it. That is expensive and error-prone.

Separate two moments. Design for these patterns from the start: clean interfaces between components, asynchronous execution at intake, and explicit failure boundaries. It is cheaper to do it sooner rather than later, and it has an enormous influence on the NAP (more than the code itself). Implement them when you cross the relevant threshold (not before): sharding, federation, and event streams are code you then have to run and debug. A NAP designed this way turns a future scaling upgrade into configuration work. Without it, every upgrade may be a rewrite.

The first of the three decisions is the most structural: how many places make decisions.

Centralization Versus Federation#

Premature optimization is the root of all evil.

Donald Knuth

The choice between centralization and federation turns less on technology than on which failure modes the organization can tolerate. A team that can accept global Orchestrator unavailability as a rare but recoverable event may stay centralized longer. A team whose operations span multiple geographic regions with independent maintenance windows will federate earlier.

This decision affects every component in the architecture. Take them one at a time, starting with the one where the trade-off is sharpest.

Orchestrator. A centralized Orchestrator has a single decision-making point: all workers report to it, all state is held in one place, all scheduling decisions are made by one component. This is simple to reason about. When something goes wrong, the failure location is unambiguous: either the Orchestrator is functioning or it is not. When a workflow needs to be debugged, all the relevant state is in one place.

The failure mode of centralization is also clear: the Orchestrator is a bottleneck and a single point of failure. At scale, the volume of state updates from thousands of concurrent workers can saturate a single Orchestrator’s processing capacity. A crash or network partition isolates all workers simultaneously.

On the other side, a federated model distributes decision-making: each regional or domain controller is responsible for its own subset of the device inventory and worker pool. The failure of one federated controller affects only its subset; others continue operating. The throughput ceiling is higher because it scales horizontally (scale-out pattern).

The cost is consistency. In a federated model, you must aggregate state from multiple controllers to get the global view of running, completed, and failed jobs. A change that spans multiple federated domains requires coordination across them. Federation rarely fails with a visible crash. It fails with small inconsistencies in the distributed state that are hard to detect and expensive to resolve.

Figure 12.1 sets the two side by side as load grows. The curves are illustrative.

Centralized against federated as load grows

Figure 12.1: Centralized against federated as load grows.

The recommendation is simple: start centralized. Federate only when you hit a concrete, measurable bottleneck. Federation adds complexity before scale justifies it: distributed state, cross-domain consistency questions, aggregated debugging across multiple controllers. That complexity is the right trade-off at scale, but it is the wrong trade-off for a NAP that has not yet demonstrated it needs it.

I have fallen into this one myself. Asked for a network that spanned several clouds, I designed something I was very proud of: a multi-cloud Border Gateway Protocol (BGP) fabric, with dynamic routing everywhere, ready for any topology the future might bring. Then I presented it to the users. They needed a handful of locations to talk to each other, and that was not going to change. We built point-to-point connections instead, automated end-to-end, and they did everything that was asked. The fabric was a beautiful answer to a question nobody had asked.

So, when should you consider federation?

Two signals justify federating. The first is scheduling throughput that saturates under load: the queue grows faster than the Orchestrator can dispatch, even with tuning. The second is a geographic reliability requirement a centralized design cannot meet, such as regions with independent maintenance windows that must keep operating when partitioned from each other. Without one of those two signals, federation is premature optimization, in Knuth’s sense. The cost of staying centralized too long is a refactoring project. The cost of federating too early is a distributed system whose complexity outpaces the team’s ability to operate it.

The Orchestrator’s workers are the easy part, and usually the first to be distributed. They hold no coordination state, as the Control Plane and Data Plane Separation section explains, so regional worker pools change nothing about who owns each job: one Orchestrator still does. Before you federate the Orchestrator itself, answer one question: does any workflow span devices in more than one federated domain, and if so, which Orchestrator owns the job state when one domain loses connectivity mid-run?

The other components face the same choice, and each has a distinct failure mode when federated.

Source of Truth. Federating the Source of Truth (SoT) raises a consistency question the Orchestrator federation does not. When the same device record exists in two regional partitions and a write occurs in one, how long until the other reflects it? And what happens when a workflow reads from one partition while the authoritative record is updating in the other? Chapter 5 covers the Source of Truth consistency model; that model is the constraint that determines how aggressively the Source of Truth can be federated.

Federating the data layer takes one of the two shapes of Figure 5.4 in Chapter 5, and the choice decides which consistency you inherit: the centralized shape serves one view but is eventually consistent only, while the distributed shape keeps strong consistency per domain, at the cost of consumers querying several systems and coordinating change events.

The same advice applies as for the Orchestrator: start centralized, and move a domain to the distributed shape only when keeping it in the central Source of Truth becomes the thing holding you back, such as a source too large or too fast-changing to keep in sync, or an availability dependency you cannot accept. Before federating, answer one question: if a workflow in region A reads a device record while a write to that record is in flight in region B, what does the workflow act on, and is that acceptable for the operation it performs?

Observability. The Observability layer is where federation pays off most clearly, because most of its decisions are local. Detecting a problem inside one data center needs no data from another. So give each region or site its own stack, able to collect, store, alert, and validate a wave on its own, and centralize only the questions that need the whole picture: fleet-wide trends, cross-region correlation, capacity planning. Each regional stack keeps working when the others (or the central view) are unreachable. Moreover, it feeds back into the central one eventually.

The cost is coordination. Someone has to keep the regional stacks consistent in schema, alert rules, and retention, and the central view only aggregates what the regions agree on. Fan-in latency is the other cost: a question that does need the central view waits for telemetry to cross the regional boundary. Before federating, answer one question: which decisions need data from more than one region, and does the post-wave validation of the Orchestrator depend on any of them?

Presentation. The API is usually the last component to federate, because users want one entry point. Regional endpoints can sit in front of it. The question to answer first: if a request is submitted in region A, can region B track, approve, or cancel it? Each request needs exactly one owning region, or two regions can approve or cancel the same change.

Evaluate each component on its own, with its own consistency requirements and failure modes. The NAP is not one tier that federates, or stays centralized, all together. The Observability case gives the test for every component: how much of its work can each part do with only local data? The more it can, the more federation buys resilience and scale; the less it can, the more you pay in coordination for little in return.

If you cannot answer a component’s question, that component is not ready to federate.

Federation decides how many places make decisions. The next decision is where the decisions end and the work begins.

Control Plane and Data Plane Separation#

A NAP ready to scale separates the work of deciding from the work of doing. The control plane decides: which workflow runs, which worker gets which device, whether a wave passed. The data plane does: it logs into devices, pushes configuration, and collects telemetry. But they grow independently. Decisions grow with the number of workflows, and the work grows with the number of devices, so a NAP that can scale each on its own handles growth where it actually arrives.

The centralization question of the previous section applies to each plane separately. The data plane is usually distributed first, because it is needed first: workers have to sit close to the devices they reach, and they hold no coordination state, so placing them by region costs little. The control plane can be federated too, later and more carefully. Whatever you distribute, check the dependencies first: a regional part that cannot act without a synchronous call to a central one has not gained independence. Split the NAP that way and you get a distributed monolith, the complexity of a distributed system with none of its resilience, because every part still fails when the center does.

The terms “control plane” and “data plane” are borrowed from distributed systems and carry a different meaning here than in network architecture, where they refer to routing protocol processing and hardware packet forwarding respectively.

Figure 12.2 shows which side each NAP component falls on.

The NAP’s components split into a control plane and a data plane

Figure 12.2: The NAP’s control plane and data plane.
  • Control plane: Presentation and the Orchestrator. Presentation takes requests in and hands them to the Orchestrator. The Orchestrator schedules workflows, assigns work to workers, tracks workflow state, and evaluates completion criteria. It acts on intent from the Source of Truth and on the Observability layer’s view of what has actually happened. It is stateful and needs consistency: its view of which workers are busy, which devices are done, and which workflows are in flight must be accurate, or scheduling goes wrong.
  • Data plane: Executor and Collector workers. Executor workers push configuration to devices and pull artifacts from the artifact store; Collector workers gather telemetry. A worker is one running instance of a component, so you add capacity by adding workers, not components. Each operation is independent of the others, so the data plane holds no coordination state. It is also where the volume lives: at tens of thousands of devices, it runs many more operations per second than the control plane schedules.

Between the planes sits a work queue, owned by the Orchestrator: it enqueues work and moves on, and workers take it at their own pace. The Scaling Patterns section opens it up.

Separating the planes contains data plane failures: a batch of crashed workers, a telemetry spike, or a device rejecting connections. None of them stops the control plane from reasoning about the system and scheduling new work. It also means the data plane can be scaled horizontally by adding workers without any change to the control plane. On the other side, the control plane can be made highly available through leader election or active-passive replication without that complexity propagating to the data plane.

A NAP that conflates control and data plane, where the Orchestrator is also the execution engine, cannot scale these concerns independently. If adding more execution capacity means adding more Orchestrator capacity, then you may not have proper separation of concerns. Small environments that do not need to scale are the exception (again).

Separating the planes leaves one problem that no architecture removes: the data both planes read is never perfectly current.

Consistency Models#

In an ideal world, we want all our data (intended and observed) to be consistent. For example:

  • In the Source of Truth, covered in Chapter 5: every read returns the most recently written intent.
  • The observed network state, covered in Chapter 7, reflects the actual state of the network.

In practice, neither holds. The data recently written may not be available due to caching or distributed data sources. Observed network data is never perfectly in sync with reality either, because collection, processing, and distribution all introduce delay.

These are not edge cases. They are the normal operating condition of any distributed system that manages physical infrastructure. The NAP that does not design for them will encounter them as operational incidents.

Three decisions must be made explicitly:

  • How long to wait. The reconciliation window: how long after a deployment does the NAP wait before querying for the post-change state? A useful starting point is two to three times the telemetry collection interval. For a NAP polling every 30 seconds, wait at least 90 seconds before declaring a validation failure; the device may still be converging.
  • What to do while they disagree. When the Source of Truth and the observed state disagree during that window, ignore is almost never the right answer; it silently discards information that may be diagnostically important. Retry fits likely transient disagreements, such as collection delay. Alert-and-wait is the default for genuine state mismatches. The NAP pages the on-call engineer with the device ID, the expected value from the Source of Truth, and the observed value from the Observability layer. Then it pauses the affected workflow at the current stage boundary. The engineer confirms the discrepancy is acceptable and resumes, or aborts and investigates. The NAP does not decide unilaterally.
  • What to do when the window expires. If they still disagree, either drift has occurred or the telemetry pipeline has a problem. Both need investigation, and the NAP cannot tell them apart without a human.

Those three decisions shape the architecture. The next section turns them into patterns you apply as the NAP grows.

Scaling Patterns#

Four patterns follow. The first two split the work and the data across more resources: worker sharding and data-layer sharding. The third keeps the pieces coordinated at volume: event-driven coordination and the messaging underneath it. The last keeps the Source of Truth, which every workflow reads first, from becoming the bottleneck.

The first three patterns each add one piece to the NAP of Figure 12.2, and the figure grows with them. Figure 12.3 opens it up: the Orchestrator’s internals, including its work queue, and the network below. Figures 12.3 to 12.5 highlight what each pattern adds.

The work queue makes the NAP asynchronous inside, whatever the requester sees (Chapter 8 covers synchronous and asynchronous execution from the requester’s side). The queue absorbs a burst of submissions, and its depth is the leading indicator of pressure before throughput degrades. The opening story’s NAP already had this queue. What it lacked was a timeout on each operation: with one, a device that never responds releases its worker, and the devices queued behind it keep moving.

The queue has a debugging cost. A workflow that fails at step three of seven has its state spread across the queue, the worker that ran steps one to three, and the dead-letter queue that caught the failure. Distributed tracing, covered in the Distributed Tracing Across Workflows section, is what makes that tractable.

Worker Sharding#

Worker sharding divides the device inventory across a set of workers so that each worker is responsible for a bounded subset. It is what turns 48 workers into 48 times the throughput, and it also decides which devices fail together when a worker dies. How you draw the subsets matters more than how many there are.

The simplest strategy is random assignment: each job distributes devices randomly across available workers. Random assignment produces even load distribution but no locality of failure. A worker that crashes affects a random sample of devices from across the fleet. That makes it hard to tell whether the failure has a systematic cause: the same site, the same firmware, or the same vendor model.

Locality-preserving sharding, or worker affinity, assigns devices to workers by a meaningful attribute: site, region, vendor, or organizational domain, read from the Source of Truth by the scheduler at dispatch time. It is the opposite of the anti-affinity that spreads NAP replicas apart in Chapter 11: here you want related devices together. A worker that owns site A handles all devices at site A. If that worker crashes, the affected devices are all at site A, which is a meaningful failure domain (covered in the Bulkheads and Failure Domains section). The impact is bounded to a geographic or organizational unit, and the correlation between the failure and the affected set is immediate. Sometimes locality is not even a choice: a site reachable only from inside its own network needs a worker there.

Figure 12.3 shows the NAP with its workers split into one pool per site, for the Executor and the Collector alike.

Worker sharding: one worker pool per site

Figure 12.3: Worker sharding: one worker pool per site.

The cost of locality-preserving sharding is uneven load distribution. A 1,200-device site produces a heavier worker than an 80-device site. The scheduling system must account for this imbalance, either by assigning multiple workers to large sites or by dynamically rebalancing as sites grow.

My recommendation: use locality-preserving sharding by site from the start, even at small scale. The load imbalance is a scheduling problem with known solutions; the failure correlation problem of random assignment is an incident investigation problem with no good solution after the fact. When a worker fails in a locality-preserving system, the affected device set is immediately meaningful: all devices at site A. When a worker fails in a random system, the affected device set is a random sample of the fleet with no diagnostic value. That difference matters most at 02:00 when the team is trying to determine whether a failure is a systematic fault or an isolated event. Random assignment optimizes for load evenness at the cost of operational clarity; that is the wrong trade-off for a system that manages production network infrastructure.

Some workflows span sites, such as a routing policy change that touches a peering router at site A and a BGP reflector at site B. Assign those a region-level worker, scoped to the devices in the workflow’s declared target set. Site-based sharding handles the common single-site case; the region-level worker handles cross-site exceptions without breaking locality for everything else.

When the fleet mixes management protocols, with some devices on NETCONF or gRPC Network Management Interface (gNMI) and others limited to Command Line Interface (CLI) scraping over Secure Shell (SSH), add protocol type as a secondary sharding attribute alongside site. A worker configured for NETCONF against a device that only accepts CLI fails immediately, and that failure is indistinguishable from a connectivity problem without a protocol-type label in the record.

Worker sharding splits the execution. It does nothing for the data: if every worker queries the same Source of Truth instance and that instance is saturated, adding workers only lengthens the queue at the database. That is the next pattern.

Data-Layer Sharding#

Data-layer sharding partitions the Source of Truth by region or domain, so each partition holds the records for a bounded subset of the device inventory. Workers assigned to a region query only that region’s partition, not the global one. The query load is spread across partitions.

A critical constraint is the alignment between worker sharding and data-layer sharding. If workers are sharded by site and the Source of Truth is partitioned by region, a worker handling a site in region A must query region A’s partition. This works. If the worker sharding and the data partitioning do not align, the worker must query across partitions to assemble its inputs. That cross-shard query is likely slower than the single-instance query it was meant to replace. The two sharding strategies must be designed together.

The solution is simple: match the Source of Truth partition boundary to the locality attribute you already use for worker sharding. If workers are sharded by region (all sites in North America to the NA worker pool, all sites in Europe to the EU worker pool), the Source of Truth should be partitioned by region. The partition boundary is a geographic or organizational one that maps to a routing domain in the physical network. Both the scheduler and the database administrator can then reason about it in the same terms. Figure 12.4 adds that alignment to the NAP.

Data-layer sharding: Source of Truth partitions aligned with the worker pools

Figure 12.4: Data-layer sharding aligned with the worker pools.

Partition by a boundary that means something to network operations, such as a region or a major data center, and not by one chosen for database convenience, such as a hash of the device name. Then a failure in one partition affects an identifiable, operationally coherent set of devices.

The cross-shard query problem is not eliminated by partitioning: some workflows span partition boundaries (a change to a routing policy that affects devices in two regions, or a global Source of Truth audit query). These queries run against a global read replica that aggregates across partitions, accepting the higher latency of a cross-partition query in exchange for the flexibility of a unified view. However, the global read replica only serves reads, and it may lag behind. Workflows that need strongly consistent global state must either be redesigned to run within a single partition or accept the consistency window of the replica.

Sharding spreads the work and the data across more resources. Coordination is the next limit: one Orchestrator scheduling everything eventually saturates too.

Event-Driven Coordination and Messaging#

Chapter 8 introduced the distinction between orchestrated and event-driven workflow coordination. At small scale, orchestrated workflows are preferable: they are deterministic, easy to debug, and their execution trace is a linear record of what happened and when.

At scale, the Orchestrator’s scheduling throughput is where orchestrated workflows saturate. If the Orchestrator can schedule N workflow instances per second, and the incoming submission rate exceeds N, the queue grows without bound. The Orchestrator becomes the bottleneck, and its failure affects all in-flight workflows simultaneously.

Event-driven architectures distribute the coordination: each completed workflow step emits an event, and downstream steps are triggered by consuming those events from a queue. The queue absorbs bursts: if the event production rate temporarily exceeds the consumption rate, the queue depth grows but the system does not fail. Workers scale horizontally by adding more consumers to the queue. The Orchestrator, in a pure event-driven system, is replaced by the queue itself.

Debugging it is not free. An event-driven workflow that fails partway through has its state distributed across the event log, the consumer offsets, and whatever state the individual steps wrote before they failed. Reconstructing the failure requires correlating across those locations. This is why distributed tracing is necessary for event-driven systems at scale, as the primary debugging tool.

The decision mirrors the federation question in Centralization Versus Federation: start orchestrated and switch to event-driven only when you hit a concrete saturation signal. Two signals justify the switch. Scheduling throughput measurably saturates under load, so the queue grows faster than the Orchestrator can dispatch even after worker tuning. Or a failure pattern shows the Orchestrator’s coordination overhead amplifying failures instead of containing them. Absent one of those signals, orchestrated workflows are easier to debug, easier to reason about, and easier to hand off to engineers who did not build the NAP.

However, this is not black or white. You can use event-driven coordination for parts like triggering while keeping orchestrated workflows for parts with stricter constraints.

The same event model applies to data. Instead of polling for a fresh Source of Truth snapshot at the start of each run, workers subscribe to its change events, as the Data Consumption section of Chapter 5 describes. They keep a local cache that is updated incrementally. A change to a device record produces an event on a message bus or a webhook. Workers that care about that device update their cache. The query cost shifts from a full inventory load on each workflow start to a small delta on each Source of Truth write.

It adds one dependency: the Source of Truth must publish reliable change events. If the event stream fails, the caches go stale silently, so keep a reconciliation cycle that periodically reloads from the Source of Truth. Not every implementation can publish them out of the box.

Whichever coordination model you choose, the events, tasks, and notifications travel as messages, and at volume the messaging layer has properties of its own. Every NAP component talks to the others through messages. The Orchestrator hands tasks to workers, the Source of Truth announces changes, collectors stream telemetry to Observability, and the Presentation layer notifies requesters. At small scale, direct API calls carry all of it. At scale, most of it moves onto a message bus, often a service the IDP already runs. Figure 12.5 completes the picture: the bus takes the work queue’s place between the planes and carries every one of those flows.

The message bus between the control plane and the data plane

Figure 12.5: The message bus between the planes.

The bus’s properties become the NAP’s properties. Five matter:

  • Delivery semantics: most buses deliver at least once, so a message can arrive twice. Processing must be idempotent: a duplicate produces the same result as a single delivery. Idempotency is covered in depth in the Reliability Engineering section; at the messaging layer the point is that the bus cannot guarantee exactly-once delivery, so the consumer must.

  • Ordering: a bus orders messages within a partition instead of globally. Partition by device, so two changes to the same device arrive in the order they were made. Global ordering does not scale, and a NAP rarely needs it.

  • Durability and replay: a bus that retains messages lets a restarted consumer resume where it stopped, and lets a new one rebuild its state from history. Without retention, a worker that crashes loses the work it had not acknowledged.

  • Explicit schemas: messages between components should have explicit, versioned schemas. A worker that receives a malformed or unexpected message should reject it with a diagnostic error and not crash or process it incorrectly.

  • Back-pressure mechanisms: when consumers cannot keep up with producers, the queue grows. Uncontrolled queue growth consumes memory and storage and eventually causes the system to reject new messages. Back-pressure is the mechanism by which the consumer signals to the producer that it needs to slow down. The specific implementation depends on the messaging system, but the design must account for the case where the data plane is overwhelmed: adding more work to an overwhelmed system makes the situation worse.

The Orchestrator still decides what runs; it now publishes tasks to the bus instead of holding them in its own queue. The Source of Truth publishes change events that keep worker caches current, and collector workers publish telemetry that Observability consumes. Adding workers still means adding consumers, with no change to the control plane.

A third coordination model is emerging: agentic workflows, introduced in the Agentic Orchestration section of Chapter 8 and built into a decision layer in Chapter 18. Their non-deterministic execution path makes load and execution prediction harder than for orchestrated or event-driven approaches, but the agent’s ability to adapt to observed failures can reduce the need for pre-coded retry and circuit breaker logic. Even so, every change an agent proposes passes the same deterministic gates as any other change.

One component deserves its own pattern set, because every workflow starts by reading it: the Source of Truth.

Source of Truth Data Retrieval at Scale#

The Source of Truth data retrieval is often invisible as a bottleneck until you cross the scale threshold. Then it becomes a crisis because everything starts from here.

A workflow that needs to process a subset of the device inventory, say all campus switches at a specific site, typically begins by querying the Source of Truth for that subset. At small scale, this query returns quickly. At tens of thousands of devices, even a filtered query against a Source of Truth that stores device records, interface records, cable connections, Internet Protocol (IP) allocations, and service assignments may return millions of rows before filtering. The query time grows with the Source of Truth’s data volume, not just with the result set size.

The design responses operate at different points in the query lifecycle:

  • Lazy fetching: load only the Source of Truth data required for the current workflow batch. A workflow targeting site A should query only site A’s records, which is more efficient than querying the global inventory. This requires the workflow to know its scope before querying, so the scheduling system has to assign each workflow its scope before it runs.

  • Pagination: never load the complete result set of a large query atomically. A query that returns fifty thousand interface records should stream them in pages of a few hundred, process each page, and release memory before loading the next. Atomic loads at this scale can cause memory pressure that affects the entire worker process.

  • Read replicas: separate the read path from the write path at the database level. Bulk reads from workers should go to read replicas that are eventually consistent with the primary. This prevents bulk read operations from competing with Source of Truth writes for database resources and degrading the write path that processes incoming changes.

  • TTL-based caching: workers that process multiple devices in a sequence can cache their Source of Truth queries with a short TTL (i.e., a cache expiry duration, not the IP packet time-to-live). The TTL is a design decision that encodes how stale the Source of Truth snapshot can be before a workflow must re-query. It is a trade-off between query load on the Source of Truth and the freshness of the data the worker is acting on.

  • Event-driven consumption: the most architecturally significant approach, covered in the Event-Driven Coordination and Messaging section: workers subscribe to Source of Truth change events instead of querying.

The observability store has the same problem on the read side. A post-wave validation query over raw, high-resolution telemetry for 800 switches is slow. Query downsampled aggregates where the decision allows it, and keep raw data for the devices under investigation. The Persistence section of Chapter 7 covers downsampling.

Those five address the read path. Writes hit the same wall from the other side, and the answer there is bulk endpoints. The arithmetic is stark: ten thousand devices updated one object at a time is ten thousand requests and ten thousand round trips, which is minutes of wall time before anything else happens. A single bulk call collapses that into one round trip the backend can parallelize.

What you give up is the thing that made single-object writes safe. Bulk endpoints skip the expensive cross-object checks to hit their throughput, and they report errors per batch rather than per object, so a partial failure leaves you working out which of ten thousand records did not land. That is the same synchronous-versus-deferred validation trade-off that Chapter 4 frames at the data layer, surfacing here as an API decision. Use bulk for machine-generated changes where the data was already validated upstream; keep single-object writes for anything a human typed.

These patterns are additive, not alternatives, and should be adopted in sequence by infrastructure prerequisite. Lazy fetching and pagination require only workflow code changes and should be standard practice from the start of the NAP build. Read replicas require a database configuration change and deliver the highest single-step reduction in Source of Truth query load; implement them when query latency first becomes a measurable bottleneck. TTL-based caching adds coordination between the workflow and a caching layer and is appropriate when read replicas alone cannot keep up with concurrent worker demand. Event-driven Source of Truth consumption is the most architecturally significant investment and is appropriate only after the other patterns are in place and the Source of Truth’s event publishing infrastructure is validated as reliable.

All of these patterns make reads faster. None of them tells the workflow how fresh its data is, and often it does not know. Chapter 5 distinguishes a Source of Truth read once, as a reference, from one read at each step, as a live dependency. At scale, the first has a failure mode worth naming.

When the Orchestrator reads device inventory at workflow start and then fans out across 200 devices, it is working from a snapshot. A device is decommissioned mid-run, or an IP address is reassigned between the snapshot and the execution step. The automation then acts on data that was correct when it was read and is wrong when it is used. For short workflows this is usually acceptable. For a firmware upgrade that runs for hours, or a provisioning run that spans a maintenance window, the staleness window is wide enough to matter.

Treat Source of Truth availability as a dependency rather than an assumption:

  • Validate that the Source of Truth read succeeded and returned a current record, by checking last-sync timestamps or the Source of Truth’s own health endpoint, before starting a fan-out step.
  • For long-running workflows, re-read the Source of Truth at each major stage rather than once at the start.
  • If the Source of Truth is unavailable, fail cleanly with a clear error. Do not proceed from a cached snapshot of unknown age. A run that silently falls back to stale intent is worse than one that stops, because nothing records that it acted on old intent.

This puts a requirement back on the Source of Truth itself. A Source of Truth that is write-authoritative for all automation but has no high-availability configuration is a single point of failure for the entire NAP. Read replicas, regional deployments, and one Source of Truth or several federated ones: these are the questions of Centralization Versus Federation, applied to the data layer the rest of the NAP reads from.

Scaling patterns make the NAP faster, but how does it behave when something breaks?

Reliability Engineering#

A distributed system is one in which the failure of a computer you didn’t even know existed can render your own computer unusable.

Leslie Lamport

Reliability engineering is the discipline of designing a system to keep delivering its service while parts of it fail. It assumes components, dependencies, and networks will fail, decides in advance how each failure is detected and contained, and measures whether the system still keeps its promise. Site reliability engineering (SRE) made it standard practice for software services; this section applies it to the NAP.

Reliability engineering covers the whole NAP: every component, and every boundary between them, not only the boundary with the network. Table 12.1 lists those boundaries. Each fails in its own way and needs a defense designed before it happens. In a NAP, the computer you did not know existed is usually the Source of Truth, the secrets store, or a device that never answers.

BoundaryTypical failureDefense
Requester to PresentationA burst of requestsThe queue absorbs it; back-pressure slows intake
Orchestrator to workersA lost worker, a duplicate messageTimeouts, idempotent tasks
NAP to Source of TruthA slow query, a stale readTimeouts, read replicas, freshness checks
NAP to ObservabilityDelayed telemetryA reconciliation window
NAP to IDP servicesRegistry or secrets store unreachableFail closed, as Chapter 11 describes
Worker to networkA hang, a rate limit, a crashed management daemon or controller APITimeouts, a circuit breaker, per-target limits
Table 12.1: The NAP’s boundaries, how each one fails, and the defense for each.

The subsections take the defenses in order. Idempotency makes a repeated operation safe. Bulkheads, named after the watertight compartments of a ship, keep a failure inside one part of the NAP. Timeouts, circuit breakers, and back-pressure stop a slow dependency from holding everything else. The last two cover failures that chain across boundaries, and the NAP going down entirely.

Idempotency#

Idempotency is the property that applying an operation more than once produces the same result as applying it once. In software, it is often treated as a convenience for retry safety. In network automation, it is a correctness requirement.

Chapter 6 covers idempotency at the device: how Ansible modules, NETCONF operations, and declarative APIs handle the “already applied” case. This section covers it across the NAP, where any message or push can repeat: a bus that delivers a task twice, a worker that restarts mid-run, a push whose acknowledgment never arrives.

Take the last one. A worker pushes VLAN 412 to a switch in Building B, and the management session drops before the switch confirms. The worker cannot tell whether VLAN 412 now exists. The safe response is to retry. If the push is idempotent, the retry finds VLAN 412 already there, and the adapter reads the “vlan-exists” response as success, the case from Chapter 10. If the push is a raw CLI sequence, the retry may run half of it twice, or fail with an error the workflow reads as a real failure, and roll back a change that was correct.

Idempotency cannot be added to a workflow after the fact without reviewing every operation the workflow performs and every device interaction it makes. The cost of retrofitting is high. Designing for idempotency from the start costs less. Represent changes as desired state declarations (not imperative sequences) and make the desired-state check part of every operation. Then confirm how each device behaves for each operation type when a change is already applied.

Idempotency makes a repeated operation safe. It does not limit how far a bad one spreads, which is the next defense.

Bulkheads and Failure Domains#

On a ship, bulkheads divide the hull into compartments, so one breach floods one compartment. The Bulkhead pattern, as Michael Nygard names it in Release It!, applies the same idea to software: partition resources so a failure in one partition cannot drain the others. Cloud providers call the same design a cell-based architecture.

For the NAP, the partitions follow failure domains: the boundaries within which a failure is contained. A three-level hierarchy covers most networks:

  • Device-level: a single device. A failure at this level affects one device and no others. This is the minimum granularity; all reliability designs should be correct at this level.
  • Site-level: all devices at a geographic or logical site. A failure at this level affects an operationally coherent group. The site is often the natural unit of blast radius for network changes: a VLAN misconfiguration at a campus affects the campus.
  • Region-level: all devices within a geographic or organizational region. A failure at this level is a major incident by any definition. NAP design should minimize the conditions under which a single change can affect an entire region.

Figure 12.6 applies the hierarchy to the NAP’s own resources.

Failure domains as bulkheads

Figure 12.6: Failure domains as bulkheads.

Give each site its own worker pool and its own queue, which is the worker affinity of the Worker Sharding section taken one step further. A firmware upgrade stuck at one site then exhausts that site’s workers, not the fleet’s. Shared components need the same thought: one Orchestrator with a concurrency limit per site, so a site with 1,200 devices cannot take every scheduling slot. Apply the pattern as soon as one site, tenant, or workflow can saturate a shared resource; for the campus NAP, that is the first bulk operation that spans more than one building.

Failure domains bound network changes too, and a limit enforced by the NAP is what stops a bug that miscalculates the target list from reaching the whole fleet. Chapter 11 owns that side: its fleet rollout policy scopes each wave to a failure domain, and its waves and approvals decide when a change crosses into the next one. Bulk changes, such as the opening story’s firmware upgrade, are where both kinds of boundary pay off most. The team in that story ran all 800 switches as one batch, with no waves, and that was part of the failure: nothing stood between the first switch and the last. Chapter 13 covers how the same boundary limits the scope of a compromised workflow.

Bulkheads contain a failure. Timeouts, circuit breakers, and back-pressure keep a slow dependency from becoming one.

Timeouts, Retries, Circuit Breakers, and Back-Pressure#

The network is reliable.

L. Peter Deutsch

Deutsch put that sentence first among the fallacies of distributed computing: assumptions every distributed system makes, and every one gets wrong. The NAP makes it at every boundary in Table 12.1.

Chapter 8 defines these patterns for the Orchestrator, in its sections on retries and resilience across block boundaries. This section applies them at every boundary of Table 12.1, at scale. Four rules cover it, each for a worse case than the one before.

Every call has a timeout. Every call across a boundary has a maximum wait: a worker waiting for a device, the Orchestrator waiting for a worker, any component waiting for the Source of Truth. The opening story had none on the worker-to-network boundary, so one silent switch held a worker for more than two and a half hours. A timeout turns an unknown wait into a known failure the NAP can act on. Set it per device class and operation: copying a firmware image legitimately takes minutes, and reading a VLAN table does not.

Retries are bounded and back off. A device that does not respond may be overloaded, mid-reboot, or faulty, and the NAP cannot tell which. An immediate retry adds load to a device that is already struggling. Use exponential backoff instead: the first retry after 1 second, the second after 2, the third after 4, up to a maximum. After a set number of attempts, mark the operation failed and escalate it.

A dependency that keeps failing is cut off. A circuit breaker counts consecutive failures against one dependency. Past a threshold, it opens: further calls fail at once instead of waiting for a timeout. Per device, it stops one misbehaving switch from consuming worker capacity through repeated connection attempts. Per component, it turns a Source of Truth outage into an immediate “Source of Truth unavailable” error instead of a pile of hung workflows. Figure 12.7 shows its three states.

The circuit breaker state machine

Figure 12.7: The circuit breaker state machine.

After a cool-down, the breaker lets one test call through. If it succeeds, the circuit closes; if it fails, the breaker opens again for another cool-down.

A dependency that is slow but alive gets back-pressure. Back-pressure slows the producer when the consumer cannot keep up. Between NAP components, the message bus provides it, as the Event-Driven Coordination and Messaging section explains. At the device boundary, the consumer is the device’s management plane, and its limits depend on the vendor, the model, and the firmware: documented caps on transactions and sessions, management processes that restart under load, and bugs in specific operations of specific releases. In brownfield fleets, one model often spans five or more firmware generations, so limits must be modeled per firmware version, not per model.

How the limit announces itself. A nightly compliance job walks the switches over Simple Network Management Protocol (SNMP). One night a bulk configuration push lands on the same chassis while the walk is running. The management daemon restarts halfway through the push. The worker sees a dropped session and cannot tell whether the configuration was applied before the crash, which is the hardest ambiguity in this chapter to resolve. Nothing was wrong with the push or the walk; together they exceeded a limit nobody had written down.

Model these limits as data instead of code: device-type and firmware attributes in the Source of Truth, read at scheduling time to set concurrency and retry policy per device. Take the values from vendor documentation first, then from the vendor’s support engineers, and only then from a controlled load test against a lab device. Discovering a device’s limit in production is the failure this design exists to prevent.

Each of these defenses protects one boundary. The dangerous failures are the ones that cross several.

Cascading Failures#

The opening scenario was not a single failure. It was a cascade, and Figure 12.8 shows its structure.

The cascade in the opening story

Figure 12.8: The cascade in the opening story.

Each missing mechanism appears earlier in this section or in the Minimum Viable Reliability Design section: a worker timeout, reassignment of the worker’s slot when the timeout fires, and queue alerting at device-group resolution. Together they interrupt the cascade at three points: before the worker is held indefinitely, before downstream devices are blocked, and before the stall goes unnoticed.

With those three mechanisms in place, the scenario resolves differently. The 48th worker’s management plane wait expires at 03:23, three minutes into the stall. The timeout is logged to the dead-letter queue with the device identifier, the last known management plane state, and the exact timestamp. The 12 queued devices are released to the next available workers and complete by 03:45. At 03:46 the on-call engineer receives a page: device sw-b-acc-17, management plane timeout after 3 minutes, site Building B, 0 other devices in the queue. The maintenance window closes with 799 successful upgrades, 1 device in the dead-letter queue with a complete failure record for morning investigation, and no unexplained gap in the audit log.

The cascade is not unusual. In distributed systems under pressure, failures tend to cascade because the components that are designed to detect and interrupt the cascade are the same components that are under pressure. Reliability engineering is the work of designing those detection and interruption mechanisms before the pressure arrives.

Cascades are also more common than they look, because the failures that start them are the ones nobody predicted. Nobody had listed “a switch that neither answers nor refuses” as a risk. You cannot enumerate the unknowns, so do not design defenses only for the causes you can name. Put guardrails on symptoms instead: a timeout on every call, an abort ratio on every rollout, an alert on progress per device group. They stop the failure you did not imagine while it is still small.

One more assumption hides in that replay: that a failed upgrade can be undone inside the same window. For firmware, rollback means a second planned reload onto the previous image, from the alternate boot partition or a boot variable set before the upgrade. It takes as long as the upgrade did, sometimes longer, and it can fail in the same ways. So budget it before the window opens. Each wave’s time slot includes its own rollback, and a wave that cannot both upgrade and roll back before the window closes does not start.

All of these defenses assume that part of the NAP is still running. Sometimes none of it is.

NAP Unavailability and Manual Continuity#

The failure modes discussed in this chapter have all assumed that at least part of the NAP is functioning: some workers are completing, the Orchestrator can schedule, the queue is draining. The reliability engineering addresses partial failures and degraded conditions. But a network incident can produce a different class of failure: the NAP is entirely unavailable. The Orchestrator is unreachable, the artifact store is down, no change workflow can run. This happens. A NAP that is itself a distributed system will experience full unavailability, however briefly, as a consequence of the same failure conditions it is designed to manage.

The question a network engineer needs answered before they stake their change process on the NAP is: what is the operational model when the NAP is unavailable and the network still needs to change?

The solution is to prepare an operational model in advance, and Figure 12.9 shows it from the moment the NAP goes down to the moment it resumes. This section is its home: Chapter 11 and Chapter 13 point here for the outage runbook.

Operating while the NAP is down: break-glass access, a change made from the last approved artifact, and Source of Truth reconciliation before automation resumes, resting on an offline runbook, a credential held outside the IDP, and an artifact store reachable without the Orchestrator

Figure 12.9: Operating the network while the NAP is down.

Two things carry the network through the outage. The first is the break-glass path from the When the Path Is Blocked section of Chapter 11: device access without the NAP, for named engineers, with its own audit trail. The second is the artifact store. Its most recent production-approved artifacts are the NAP’s last-known intent, so if the NAP stops mid-operation, the last-deployed artifact for each device is the baseline for any manual change: the engineer knows what the NAP meant to deploy, because the artifact exists and was validated before the failure. Before any maintenance window or bulk operation, confirm that the store is reachable and the current artifacts are retrievable.

Both depend on three things prepared before the outage:

  1. The artifact store must be reachable without the Orchestrator. A store that is only reachable through the Orchestrator’s API is down when the Orchestrator is.
  2. The break-glass credential must live outside the NAP’s secrets store. That store belongs to the IDP, and an IDP outage is one of the ways the NAP goes down.
  3. The on-call runbook must work with nothing running. It documents the break-glass procedure and the artifact query without assuming any NAP or IDP component is up. A runbook in a wiki hosted on the same IDP goes down with it. Two solutions work: a printed copy in a physically secured place, such as a rack cabinet or a network operations safe, or a separate out-of-band wiki that shares no components or credentials with the NAP or the IDP. Rehearse it, and update it after every use.

When the NAP recovers, the first operation before resuming automated deployments is the Source of Truth reconciliation step that the When the Path Is Blocked section of Chapter 11 prescribes. Any device touched by a manual change during the outage must be reconciled against the Source of Truth before the NAP applies new automated changes. A NAP that resumes deployment against a device in an unknown manual state will produce results that differ from what the Source of Truth’s desired state would predict.

Replicas are not backups. A read replica protects the Source of Truth from a lost host; it copies a bad bulk write to every replica within seconds. Back up the Source of Truth database, the artifact store, and the Orchestrator’s workflow state, and decide how much recent data each restore may lose. For intent, an hour of lost proposals is an inconvenience; a lost day can mean reconstructing changes that are already on the network. Then restore from those backups on a schedule, into a test environment. A backup nobody has restored is a hope, not a plan.

Every defense in this section needs evidence that it works: data from production, and tests before production finds the limits for you.

Observing and Testing the NAP at Scale#

A NAP at scale has to be observed like any other service, and tested like one before production finds its limits. This section covers both, in order: service levels for the NAP, tracing across its components, then load testing and chaos testing. Its subject is the NAP itself, and it is where the NAP’s own metrics are defined. Chapter 7 lists the signals to collect, and Chapter 11 puts the stack that holds them on the IDP. Chapter 15 applies the same service-level tools to the network services the NAP delivers.

Scale also adds cost, and observation is where you see it. Each worker adds compute, the message bus’s retention grows with message volume, and traces grow with every request: keep every failed or slow one, and sample a fraction of the healthy ones. Network telemetry is usually the larger bill, and the Persistence section of Chapter 7 covers sampling and retention for it. The IDP’s autoscaling (Chapter 11) removes the work of adding workers, not the decision: give it a floor and a ceiling, and tune it to sustained queue growth instead of a spike that clears in minutes.

Service Levels for the NAP#

Service levels turn the NAP’s health metrics into a promise: what the operators and workflows that depend on the NAP can expect from it. The promise matters beyond the network team, because other teams build their own promises on top of it. An application team whose release needs a VLAN can only promise a release time if it knows how long the VLAN takes. The network services of Chapter 15 are built from the NAP’s targets upwards. A NAP with no stated service level forces every team above it to guess, and each guess hides the risk in someone else’s promise. The three-level hierarchy from SRE provides the vocabulary:

  • A Service Level Indicator (SLI) is a quantitative measurement of a specific aspect of service behavior. The NAP has four:

    • Request completion time: from request to verified result.
    • Successful change rate: the fraction of requests that complete. Break it down by gate to find the cause: a high failure rate at SoT integrity points to data quality, and a high rate at simulation means lab coverage is falling behind the network.
    • Time-to-feedback: until the requester gets a first result they can act on. It is the one users feel, and Chapter 11 explains why it decides whether engineers stay on the golden path.
    • Queue drain time: how long the queue takes to clear at the current arrival rate.

    Some of these depend on the IDP: runtime capacity sets queue drain time, and registry latency adds to completion time. Track the IDP’s own service levels as inputs, so a degradation points to the right layer.

    In brownfield fleets where legacy devices support only SNMP polling or syslog, the post-wave validation step must wait two to three polling intervals before declaring a result. Reflect that longer window in per-device-type targets, rather than in a single global threshold.

  • A Service Level Objective (SLO) is a target value for an SLI: “the 95th percentile workflow completion time should be under 15 minutes”. SLOs are internal targets. They define what “healthy” means for the NAP. Breaching an SLO is an operational signal, not a contractual event. It means the NAP’s reliability is degrading and the cause should be investigated.

    For the campus NAP, here are concrete starting targets calibrated to actual workflow scope. Workflow completion time p95 stays under 8 minutes for a VLAN add on Building B’s 24 switches. A fleet-wide firmware upgrade across 800 devices completes inside its maintenance window, with a p95 per-device upgrade time, from image staging through reload to verification, under 20 minutes. The successful change rate SLO is 99.5% over any rolling 30-day window. These numbers are achievable on a well-instrumented NAP and give the team a calibration point before the first incident reveals what “degraded” actually looks like.

  • A Service Level Agreement (SLA) is a commitment made to the operators and teams that depend on the NAP. The Service Levels for Network Services section of Chapter 15 applies the same model to the network services the NAP delivers, built from the bottom up. The SLA is derived from the SLO with a margin. If the NAP’s internal SLO is a 95th percentile under 15 minutes, the SLA promised to consumers should be a value the NAP meets even under pressure.

Figure 12.10 shows how the three relate.

SLI, SLO, and SLA for the NAP

Figure 12.10: SLI, SLO, and SLA for the NAP.

The Error Budget is the unreliability the SLO allows. With a successful change rate SLO of 99.5% over 30 days, the budget is 0.5%: about five failed changes in every thousand. The SLA sits below the SLO, so spending the budget never breaks the commitment to operators. Teams that manage the NAP as a product use the error budget to make explicit decisions. When the budget is healthy, the team has headroom for higher-risk changes. When it is depleted, reliability work comes before any new risk. Reliability incidents consume the budget unintentionally; risky changes spend it deliberately.

Start with the successful change rate. It is the one metric that directly answers whether the NAP is doing its job. A NAP with a 95% successful change rate has a problem regardless of how fast it runs. Completion time matters only after the NAP is succeeding: fast failure is not a useful property. Queue drain time is a leading indicator of saturation that becomes meaningful only once you have a baseline of normal operation to compare against. The instrumentation sequence is therefore: successful change rate first (does it work?), then completion time p95 (does it work fast enough?), then queue drain time (is it keeping up with demand?).

Service levels say whether the NAP keeps its promise. When it does not, tracing says where.

Distributed Tracing Across Workflows#

A single network change touches multiple building blocks: the Source of Truth provides the intent, the Orchestrator schedules the workflow, the Executor applies the configuration, the Observability stack records the result. Each of these touchpoints is a separate system. A failure between two of them, such as the Orchestrator’s handoff to the Executor or a worker’s query to the Source of Truth, shows its symptom at one end and its cause at the other. The workflow did not complete; the Source of Truth query timed out because a read replica was lagging.

Distributed tracing connects these touchpoints into a single trace that spans the entire workflow execution. Each component propagates a trace identifier through its operations. When the workflow completes or fails, the full trace is queryable: it shows the sequence of operations, the timing of each, and the point at which any failure occurred. The Orchestrator-to-Executor handoff that failed can be correlated with the Source of Truth query that immediately preceded it. The Source of Truth query latency spike can be correlated with the scheduled export that was running concurrently. OpenTelemetry is the common open standard for this: its libraries propagate the trace context between components, and backends such as Jaeger or Grafana Tempo store and display the result. Figure 12.11 shows what a trace looks like for one firewall request.

A trace view for one firewall request

Figure 12.11: A trace view for one firewall request.

From the requester’s side, the request was simply slow. The trace shows that 31 of its 41 seconds went to one Source of Truth query against a lagging read replica, a cause no single component’s log would have shown.

A trace produced here is also an audit artifact. The Evidence: Proving It section of Chapter 13 covers how to make that audit trail tamper-evident, complete, and queryable, turning the distributed trace into governance evidence rather than just a debugging tool.

The Resilience Across Block Boundaries section of Chapter 8 designs those boundaries. Distributed tracing makes them visible: it is the mechanism by which the network automation team can see whether a failure at a block boundary is a consistent pattern or an isolated event.

Observation shows how the NAP behaves under the load it has today. Testing shows how it will behave under the load it will have.

Load Testing#

Load testing determines the NAP’s maximum sustainable throughput: how many concurrent workflow runs can it handle before latency degrades, failure rates rise, or queue depth grows without bound? The test procedure submits workflows at increasing rates and measures the NAP’s behavior across each step. Look for the rate at which the NAP starts to degrade. It is a more useful point than the one where it collapses, so the network automation team knows the margin between current load, as the NAP’s own observability measures it, and that point. Figure 12.12 shows the shape of a typical result.

A load test result

Figure 12.12: A load test result: throughput levels off where latency starts to climb.

The knee, where p95 completion time starts to climb, is the number to plan against, not the saturation point beyond it. The distance between today’s load and the knee is your headroom; when growth eats half of it, add capacity or start the next scaling pattern.

Standard load testing tools apply here: Locust (Python-based, scriptable, good for API-heavy services), k6 (JavaScript, native Hypertext Transfer Protocol (HTTP) and WebSocket support), and Gatling (JVM-based, strong reporting) all support the kind of workflow submission patterns the NAP exposes. The key adaptation is parameterizing the test with realistic workflow payloads instead of generic HTTP requests.

Sustained load testing is distinct from spike testing. A NAP that handles 200 concurrent workflows for 10 minutes may not handle 200 concurrent workflows for 8 hours: memory leaks, log file growth, database connection pool exhaustion, and other slow-accumulating resource constraints appear only under sustained load. The test must run long enough to reveal these effects.

Test one component at a time. You do not need to test against live devices or real external systems to get meaningful results. Mocking integrations isolates the component under test: a mock Source of Truth that returns predictable data removes the Source of Truth as a variable when you want to measure worker throughput alone. A mock device API that introduces configurable latency lets you test how workers behave when devices respond slowly, without needing a real slow device. Once each component has its own baseline, run the whole NAP together; a combined test that fails without baselines tells you that something saturated but not what.

This goes beyond load testing: simulating degraded performance on purpose reveals reliability gaps. Give a mock Source of Truth 5-second response times, and it shows whether workers time out, whether the circuit breaker opens, and whether the queue alert fires at the right threshold. None of it touches production.

Load tests find the limits of a healthy NAP. Chaos tests find out what happens when part of it is not healthy.

Chaos Testing#

Chaos testing introduces failures into the NAP on purpose to discover how it behaves under conditions that normal testing does not produce. The firmware upgrade scenario from this chapter’s opening could have been discovered before the overnight run. A chaos test that injects a device that never responds would have shown whether the NAP had a worker timeout. It would also have shown whether the queue reassigned the blocked device, and whether the alerting noticed.

Start narrow, and late. The four failure modes listed below, injected in a lab against defenses you have already built, are part of the minimum design at the end of this chapter. Anything broader, such as experiments against production, belongs to a mature NAP whose basic defenses are in place and measured. Before that, chaos tests only rediscover gaps you already know about.

Netflix’s Chaos Monkey, the tool that popularized deliberate failure injection in production systems, works by randomly terminating instances in a running service to prove that the system tolerates instance loss. The same principle applies here: randomly terminating a worker process, injecting a network partition, or blocking a device’s management port in a staging environment should produce observable, recoverable NAP behavior. If it does not, the gap belongs in the backlog, not in the incident retrospective.

Every chaos test runs the same loop, shown in Figure 12.13.

The chaos testing loop

Figure 12.13: The chaos testing loop.

Start with a hypothesis you can measure: “when a worker dies mid-run, the queue reassigns its devices within 2 minutes and no device is configured twice.” Inject the fault, and watch the NAP’s own SLIs, alerts, and queue depth. If the NAP recovered as stated, keep the test; it joins the suite that runs before each major NAP release. If it did not, the gap goes to the backlog, and the test runs again once it is fixed.

Four failure modes are worth injecting first:

  • A worker process that crashes mid-deployment, with in-flight operations that may or may not have completed before the crash.
  • A network partition between the Orchestrator and the workers, causing the Orchestrator to lose visibility into worker state while the workers continue attempting operations.
  • A Source of Truth that responds slowly or returns errors, to test whether workers handle Source of Truth dependency failures gracefully or block indefinitely.
  • A device that accepts connections but never sends a response, to test worker timeout behavior.

All these integrations can be mocked to customize how they behave instead of using actual production systems (you may not be ready for testing in production). For example, the simulation environment from Chapter 10 is the appropriate target for chaos testing: it provides a realistic device fleet without the consequence of production failures. A chaos test that crashes workers against a simulated campus topology produces the same NAP-level failure modes as a production incident without affecting real users.

With the defenses, the evidence, and the tests described, the remaining question is where to start.

The Minimum Viable Reliability Design#

You now know the full reliability model. Where do you start, with a NAP already running bulk changes? With the five stages in Figure 12.14. Four are built in the NAP; one, the highly available control plane, comes from the IDP. Each stage closes a gap that the opening story exposed or would have exposed next, and each is useful on its own.

The minimum viable reliability design

Figure 12.14: The minimum viable reliability design: five stages.
  1. Timeouts at every boundary, with a dead-letter queue (NAP). Every call across a boundary in Table 12.1 has a maximum wait. Every worker operation against a device has one too, configured per device class and operation type. When the timeout expires, the operation is marked as failed and moved to a dead-letter queue: a persistent record containing the device identifier, the failure reason, the last observed state, and the exact timestamp. No worker can be blocked indefinitely by a non-responding device. The slot is released and reassigned. This stage is complete when no worker can wait indefinitely for a device response, and every timeout produces a retrievable record with the device identifier, the failure timestamp, and the last known device state.

  2. Queue and worker metrics by device group (NAP). Global queue depth is the wrong signal for the scenario’s secondary gap. Twelve devices waiting in a 48-worker system is not unusual; twelve devices waiting at the same site while all other sites complete is a reliability signal. The alert fires at the device-group level: if devices sharing a site attribute are not making progress while devices elsewhere are completing, the on-call engineer receives a page with the specific site and device count. These metrics are also the first SLIs of the Service Levels for the NAP section. This stage is complete when a stuck device group generates an alert within a defined window, regardless of whether the global success rate appears healthy.

  3. Bulkheads: worker pools split by site (NAP). Each site gets its own worker pool and queue, and the Orchestrator caps how many scheduling slots one site can take. A stuck site can then exhaust only its own workers. This stage is complete when a chaos test that stalls one site’s devices leaves every other site’s throughput unchanged.

  4. A highly available control plane (IDP). The Orchestrator runs as replicas on different hosts, with durable workflow state, still one logical Orchestrator and not a federation. The Source of Truth has read replicas, and the work queue, or the message bus once you have one, retains messages. The IDP provides the replicas, the anti-affinity of Chapter 11, and the managed databases; the NAP’s part is to run on them. This stage is complete when stopping any single control plane instance mid-run loses no in-flight workflow.

  5. A load test baseline and chaos tests (NAP). Measure the NAP’s knee, and write one chaos test for each failure mode in Table 12.1. This stage is complete when the knee is known, and every chaos test passes before each major NAP release.

Stages 1 and 2 alone would have closed the opening story. The upgrade that ended at 06:00 with twelve unpatched switches would have finished by 03:45, with one device in the dead-letter queue and a complete record. Stages 3 to 5 keep the next incident inside one site, survive the loss of a control plane host, and replace guesses about capacity with measurements. The full model goes further: federation, event-driven coordination, error budgets.

Summary#

Hope for the best, and expect the worst. Chapter 11 built the NAP. This chapter makes it survivable under the worst circumstances: an overloaded inner tool, a network disruption, etc.

This chapter collects lessons and guidelines from SRE practices, defining the separation between the NAP control and data planes and how they interact, different sharding patterns for execution and data allocation, countermeasures (e.g., timeouts, retries, circuit breakers, and back-pressure), and how to limit the blast radius impact of changes to keep the outcome, the network status, as reliable as possible.

Moreover, it is not only about performing but also about measuring the service level to support the Confidence Ladder that Chapter 14 introduces to promote the adoption of automation in the organization.

And do not forget to account for the whole NAP being down (it will happen). Get ready for that, so you have a clear procedure to execute when it happens.

Chapter 13 moves on to the unanswered question of how to ensure that the NAP operates under a governance policy.

References#

  • Designing Data-Intensive Applications, Martin Kleppmann (O’Reilly, 2017). The definitive treatment of replication lag, partitioning strategies, consistency models, and stream-processing trade-offs.
  • Site Reliability Engineering, Betsy Beyer, Chris Jones, Jennifer Petoff, and Niall Richard Murphy (O’Reilly, 2016). The foundational text on SLI/SLO/SLA design and error budgets; the service-level model in the Observing and Testing the NAP at Scale section is grounded directly in this work. (Full text free online.)
  • Release It!, 2nd Edition, Michael T. Nygard (Pragmatic Bookshelf, 2018). The original treatment of circuit breakers, bulkheads, and stability patterns; the bulkhead, timeout, and circuit-breaker patterns in the Reliability Engineering section trace to this book.
  • Designing Distributed Systems, Brendan Burns (O’Reilly, 2018). Practical patterns including sharding, event-driven coordination, and back-pressure; directly applicable to the scaling patterns in the Scaling Patterns section.
  • Chaos Engineering, Casey Rosenthal and Nora Jones (O’Reilly, 2020). The principled approach to injecting failures into production systems to discover reliability gaps; the chaos-testing approach in the Observing and Testing the NAP at Scale section is grounded in this framework.

💬 Found something to improve? Send feedback for this chapter

📖 Enjoying the book? It is also available on Kindle and in paperback. Get it on Amazon →