Over the course of this module, the Rutaverde platform has gained capacity piece by piece: several instances behind load balancers, a cache, a data layer divided by function, and event-based communication. It has also gained pieces. RouteManager had one application server and one database; the platform already has more than a dozen components spread between a data center and a cloud. More pieces mean more things that can fail, and the business's first requirement, NFR-01, demands 99.9% availability for the critical functions: 43.2 minutes of downtime per month at most. In this lesson, the last of the module, we will see how the availability of a composite system is calculated, how single points of failure are eliminated, and which patterns keep the failure of one piece from becoming the failure of the whole. We will close with the complete diagram of the target architecture and a check of it against the requirements.

Contents

  1. Availability, fault tolerance, and resilience
  2. Eliminating single points of failure
  3. Active-active and active-passive redundancy
  4. Composite availability: in series and in parallel
  5. Availability zones and regions
  6. Resilience patterns
  7. Automatic database failover
  8. Introduction to chaos engineering
  9. The target architecture of the Rutaverde platform

  1. Availability, fault tolerance, and resilience

These are three related concepts that are worth separating:

Concept What it is Question it answers
Availability A measure: the proportion of time during which the service works How much of the time is it operational?
Fault tolerance A design property: continuing to work normally even if a component fails Does it keep working if this breaks?
Resilience A broader capability: absorbing failures and overloads, degrading in a controlled way, and recovering How does it behave when things go wrong, and how long does it take to come back?

Availability is the result; fault tolerance and resilience are the means. The difference between these two is one of ambition. Fault tolerance aims for the user not to notice the failure, and it is achieved mainly through redundancy. Resilience accepts that some failures will be noticed and aims for them to be noticed as little as possible and for as short a time as possible. A system that tolerates the failure of a server may not be resilient at all when faced with an external provider that responds slowly.

Both develop Rutaverde's principle P4: Everything fails, and we plan for it.

  1. Eliminating single points of failure

A single point of failure (SPOF) is any component whose breakdown, on its own, stops the service. The method for finding them is simple and somewhat tedious: go through the diagram piece by piece and ask "what happens if this disappears right now?"

Let's apply it to RouteManager and see what the module has done with each one:

Single point of failure in RouteManager Situation after the previous lessons
app-01, the only active instance Solved: three instances behind a load balancer
Single Nginx proxy Solved: lb-01 and lb-02 with a virtual IP
Session in the memory of app-01 Solved: redis-dc-01 and redis-dc-02
SMS provider inside the delivery confirmation Solved: asynchronous communication
Maps provider, with no timeout Pending
db-01, the only database for writes Pending
Link between the data center and the cloud Pending
The Zaragoza data center as the only site Pending, and outside the scope of this module

Single points of failure are not just machines. An external provider, a network link, a certificate that expires, or the only person who knows how to perform an operation are single points of failure too. This lesson deals with the first three pending items; the fourth belongs to business continuity, in Module 4.

  1. Active-active and active-passive redundancy

Redundancy means having more than one component capable of doing the same job. It is organized in two ways:

  • Active-active: all the copies work at the same time and share the load. If one fails, the others absorb its share.
  • Active-passive: one copy works and the other waits, ready to replace it. The switch is called failover.
Aspect Active-active Active-passive
Use of resources All of them work The passive copy sits idle
Recovery time Almost zero The time to detect the failure and fail over
Complexity High if there is state to synchronize Lower
Suitable for Stateless components Stateful components, where only one must write
At Rutaverde Instances of the monolith, of Tracking, and of Notifications Data center load balancers, session store, databases

Two sizing rules:

  • N+1. If N instances are needed for the load, N+1 are deployed, so that the loss of one does not leave the rest saturated. It is the rule that led us to five instances of the monolith in peak season.
  • A passive copy that is not tested is not a copy. RouteManager's standby app-02 is the example: it existed, but bringing it up took 40 minutes and nobody was sure it would work. Failover must be automatic and rehearsed regularly.

  1. Composite availability: in series and in parallel

The availability of a system is calculated from that of its components, depending on how they are combined.

In series: the request needs all of them to work. The availabilities are multiplied, and the result is always worse than the worst of the components.

availability in series = a1 × a2 × a3 × ...

In parallel: it is enough for any one of them to work. The set only fails if all of them fail at the same time.

availability in parallel = 1 − (1 − a)^n       for n copies with availability a

With two copies at 99%, the set reaches 1 − 0.01² = 99.99%. Redundancy turns two nines into four.

Let's apply it to the shipment creation chain, with these starting hypotheses for each component in isolation: load balancer, 99.9%; one application instance, 99.5%; database server, 99.9%; network and general services of the data center, 99.95%.

def in_series(*availabilities):
    total = 1.0
    for a in availabilities:
        total *= a
    return total

def in_parallel(a, copies):
    return 1 - (1 - a) ** copies

MINUTES_PER_MONTH = 43_200

route_manager = in_series(0.999, 0.995, 0.999, 0.9995)
creation = in_series(in_parallel(0.999, 2), in_parallel(0.995, 3), 0.9999, 0.9995)
tracking = in_series(0.9999, in_parallel(0.995, 2), 0.9995)

for name, a in [("RouteManager today", route_manager),
                ("Shipment creation", creation),
                ("Tracking", tracking)]:
    print(f"{name}: {a * 100:.2f}%, {MINUTES_PER_MONTH * (1 - a):.0f} min of downtime per month")

Explanation:

  • in_series takes any number of availabilities, expressed as fractions, and multiplies them.
  • in_parallel applies the formula for redundant copies: (1 - a) ** copies is the probability that all of them fail at once.
  • MINUTES_PER_MONTH is the number of minutes in a 30-day month. The underscore just makes the number easier to read.
  • route_manager models the current chain: one load balancer, one instance, one database, and the data center, all in series.
  • creation models the new chain: a pair of load balancers, three instances, the database with a standby replica and automatic failover, to which we assign 99.99%, and the same data center.
  • tracking models the service in the cloud: the managed entry point (CDN and load balancer), at 99.99%; two instances in parallel; and db-tracking in two zones, at 99.95%.
RouteManager today: 99.25%, 323 min of downtime per month
Shipment creation: 99.94%, 26 min of downtime per month
Tracking: 99.94%, 27 min of downtime per month

Four takeaways from this result:

  • The model reproduces reality. The calculated 99.25% matches the 99.2% measured in RouteManager. Four "fairly reliable" components in series give a system that is not.
  • The new design fits within the budget. 26 and 27 minutes against the 43.2 that NFR-01 allows.
  • The weak link has changed. Of the 26 minutes for shipment creation, almost 22 correspond to the data center, the only element with no redundancy. Adding a fourth application instance would improve nothing; the next step for improvement is the site.
  • Tracking does not depend on the data center. Neither db-01 nor the link appears in its chain. When we evaluated the architecture in the previous module, we noted that the availability of tracking depended heavily on that link. With its own data and events, what depends on the link is how up to date the data is, not whether the service responds.

And one essential caveat: the parallel formula assumes that failures are independent, and in practice they are not entirely so. Three instances with the same programming defect fail at once; two servers in the same room share a power supply. The calculation gives an optimistic ceiling. Real availability is known by measuring it, which is what we defined the service level indicators for.

  1. Availability zones and regions

Cloud providers organize their infrastructure at two levels:

  • A region is a geographic area, for example a country or a part of one.
  • An availability zone is one or more data centers within a region, with power, cooling, and networking independent of those of the other zones, and connected to one another with very low latency.
Deployment Failure it tolerates Cost and complexity
One zone That of a machine Low
Several zones in one region That of an entire data center Moderate; it is the usual practice
Several regions That of an entire region High: long-distance data replication

Spreading a service across zones is high availability: the failure of one zone is absorbed without intervention. Rutaverde's cloud services are deployed in two zones, A and B, of a single European Union region: the Tracking and Notifications instances are spread across both, and the managed services (cache-tracking, db-tracking, and event-bus) have their primary copy in one and their replica in the other.

Deploying in several regions answers a different question, that of what to do if an entire site is lost, and that is no longer high availability but disaster recovery. Its objectives, RPO and RTO, the backups, and the corresponding plan are studied in Module 4, together with the case of the Zaragoza data center, which today is a single site.

  1. Resilience patterns

Redundancy protects against components that go down. Resilience patterns protect against something more frequent and more harmful: components that respond badly or slowly. A slow dependency is worse than an outage, because it ties up the caller's resources and propagates the problem backward. This is the cascading failure.

Timeouts

A timeout is the limit the caller sets for itself before considering a call failed. It is the most basic pattern and the most often forgotten: remember that RouteManager calls the maps provider without one, so that when the provider hangs, the application's threads sit waiting until they run out.

Call Timeout
Application to cache-tracking 50 ms
Waiting for a connection from the database pool 2 s
Load balancer to instance: connection and response 2 s and 10 s
Monolith to the maps provider 2 s
Notifications to the SMS and email provider 3 s

The consistency rule: the timeouts of the inner calls must fit within the timeout of whoever contains them. If the load balancer waits 10 seconds, the sum of what the application may wait for its dependencies must be less.

Retries with exponential backoff and jitter

Many failures are fleeting and are solved by retrying. We already saw exponential backoff in the previous lesson. What remains is to justify the jitter: if a thousand clients fail at once and all of them retry exactly after 1, 2, and 4 seconds, the service receives a thousand simultaneous requests in each wave. By adding randomness, the waves are spread out.

import random

def wait_before_retry(attempt, base=1.0, cap=60.0):
    exponential = min(cap, base * 2 ** (attempt - 1))
    return exponential * random.uniform(0.8, 1.2)
  • base * 2 ** (attempt - 1) gives 1, 2, 4, 8, 16 seconds for attempts 1 to 5.
  • min(cap, ...) keeps the wait from growing without limit.
  • random.uniform(0.8, 1.2) multiplies by a random value between 0.8 and 1.2: a variation of 20% up or down.

Retries come with strict conditions: only for idempotent operations, only on transient errors, with a maximum number, and in a single layer. If the client retries 3 times, the load balancer 3, and the application 3, one failed request turns into 27.

Circuit breaker

When a dependency is down, continuing to call it is useless and harmful: every call consumes a full timeout. The circuit breaker watches the calls to a dependency and, when it detects too many failures, stops calling it for a while and fails immediately.

stateDiagram-v2
    [*] --> Closed
    Closed --> Open: half of the last 20 calls fail
    Open --> HalfOpen: 30 seconds pass
    HalfOpen --> Closed: 3 successful trial calls
    HalfOpen --> Open: a trial call fails
  • Closed: normal operation. Calls go through and failures are counted.
  • Open: calls are not made. An immediate error or a fallback is returned. The dependency gets a rest and the caller does not waste resources.
  • Half-open: after a while, a few trial calls are let through. If they go well, the circuit closes; if not, it opens again.

The name comes from electricity, and the analogy is exact: a closed circuit lets the current through. Rutaverde will apply it to all external dependencies: the maps provider, the SMS and email provider, and the accounting ERP.

Bulkheads

Bulkheads are the walls that divide a ship's hull into watertight compartments: a leak floods one compartment, not the ship. In software, the pattern consists of separating resources by function so that the exhaustion of some does not affect others.

Bulkhead at Rutaverde What it isolates
mono-batch-01 separated from the main group Reports and scheduled jobs do not consume the capacity for shipment creation
db-02 for reports Heavy queries do not compete with writes
Separate Tracking and Notifications services A flood of queries does not affect the monolith
One queue per consumer A slow consumer does not delay the other
Limit of 20 simultaneous calls to the maps provider per instance A slow provider does not exhaust the application's threads
Different rate limits for positions and for delivery confirmations The flood of positions does not harm the confirmations

As you can see, much of this module has consisted of putting up bulkheads without calling them that.

Graceful degradation and fallbacks

Graceful degradation is the ability to keep offering the essentials when the non-essentials fail. Its instrument is the fallback: what is done when the normal option is not available.

Failure Degraded behavior
Maps provider unavailable The shipment is created anyway and is flagged with geocoding pending, which is completed later asynchronously
cache-tracking unavailable db-tracking is queried directly: slower, but it works
db-tracking unavailable Whatever is in the cache is served; for the rest, a clear message that the status cannot be checked at this time
Link between the data center and the cloud down The monolith keeps operating and accumulates events in the outbox; tracking shows the last known status with its time
SMS and email provider down Notifications wait in their queue and are sent on recovery
db-02 unavailable Reports are temporarily unavailable
General overload Whatever exceeds the limit is rejected early, with 503 and Retry-After, and delivery confirmations are given priority

Note the next-to-last row. The temptation is to redirect reports to the primary "in the meantime." We do not: it would reproduce exactly the incident that led to separating the reports. It is consistent with the requirements, which ask for 99.5% for reports and 99.9% for shipment creation. Degrading well means deciding in advance what is sacrificed to protect what.

  1. Automatic database failover

The most important single point of failure remains: db-01. The solution combines three elements we already know, replication, active-passive redundancy, and health checks:

  • A standby replica, db-03: a server with the same specifications as db-01, in the data center, with synchronous replication. Every committed transaction is on both servers.
  • A failover manager that watches the primary and, if it stops responding, promotes the replica. Patroni is a well-known example of this category for PostgreSQL.
  • A stable address, db-primary.internal.rutaverde.example, which always points to the current primary. Applications connect to it and do not need to know which server is behind it.
sequenceDiagram
    participant A as Monolith instances
    participant G as Failover manager
    participant P as db-01
    participant R as db-03
    G->>P: Health check
    Note over P: db-01 stops responding
    G->>P: Failed checks for 10 s
    G->>R: Promote to primary
    R-->>G: Promoted
    G->>A: The stable address now points to db-03
    A->>R: Reconnection and retry of the operations

The goal is to complete the failover in under 60 seconds. During that interval writes fail, and here you can see how the pieces of the module fit together: merchants retry with their idempotency key, the courier app stores the confirmations and resends them, and tracking keeps responding from its own store. One failover consumes one minute of the 43.2 in the monthly budget.

There are two specific risks that the design must cover:

  • Split brain. If the manager mistakenly believes that the primary has gone down, for example because of a network cut between the two, and promotes the replica, there would be two primaries accepting different writes. This is avoided by requiring a majority: the manager relies on three consensus nodes, the two servers and a lightweight witness, and only whoever retains two of the three votes acts.
  • The synchronous replica as a brake. If db-03 fails, synchronous replication would stop the writes on db-01. Rutaverde's decision is that, in that case, db-01 continues in asynchronous mode and an alert is raised: continuing to provide service is preferred.

db-02, the asynchronous read replica, keeps its role for reports. How much data can be lost and how long it can take to recover the service if the entire data center is lost are the RPO and RTO objectives of NFR-14, which are set in Module 4.

  1. Introduction to chaos engineering

Everything above is a hypothesis until it is verified. Chaos engineering is the practice of causing failures deliberately and in a controlled way to verify that the system reacts as designed, before a real incident proves it.

It does not mean breaking things at random. An experiment has a method:

  1. Formulate a hypothesis: "if mono-02 is shut down, no request fails and the p95 stays below 300 ms."
  2. Limit the scope: start in a test environment and with the least possible impact.
  3. Cause the failure and watch the metrics.
  4. Have a stop button and know how to roll back.
  5. Learn: if the hypothesis does not hold, a weakness has been found in time.

Rutaverde will start modestly. Before each peak season it will hold a drill day in the pre-production environment, with three experiments: shutting down an instance of the monolith, cutting the link between the data center and the cloud, and forcing the failover from db-01 to db-03. Its value depends on being able to observe what happens, and observability is the subject of Module 4.

  1. The target architecture of the Rutaverde platform

This is the result of the module: the target architecture of the platform after decisions ADR-004 to ADR-008.

flowchart TB
    MER["Merchants: portal and API"]
    COU["Couriers: mobile app"]
    STAFF["Internal staff"]
    REC["Recipients"]
    SMS["SMS and email provider"]
    MAP["Maps provider"]
    ERP["Accounting ERP"]
    CDN["CDN"]

    subgraph DC["Zaragoza data center"]
        VIP["Virtual IP"]
        LB["lb-01 active and lb-02 standby: Nginx"]
        MONO["Main group: mono-01 to mono-03, up to mono-05 in peak season"]
        BATCH["mono-batch-01: scheduled jobs and reports"]
        REDIS["redis-dc-01 and redis-dc-02: sessions"]
        DB1["db-01: primary, schema per module, outbox"]
        DB3["db-03: synchronous standby replica"]
        DB2["db-02: asynchronous read replica"]
        NAS["NAS: photos, labels, and temporary files"]
    end

    subgraph CLOUD["Public cloud, EU region, zones A and B"]
        LBN["Managed layer 7 load balancer"]
        TRK["Tracking: 2 to 8 instances"]
        CACHE["cache-tracking"]
        DBT["db-tracking"]
        BUS["event-bus: topic shipments.events, two queues and their DLQs"]
        NOT["Notifications: 2 to 6 instances"]
        OBJ["Object storage: static files, archive, and backups"]
    end

    MER --> VIP
    COU --> VIP
    STAFF --> VIP
    VIP --> LB
    LB --> MONO
    LB -->|"path /reports/"| BATCH
    MONO --> REDIS
    MONO --> DB1
    MONO --> NAS
    MONO -->|"with circuit breaker"| MAP
    BATCH --> DB1
    BATCH -->|"billing, with circuit breaker"| ERP
    BATCH -->|"read only"| DB2
    DB1 -->|"synchronous"| DB3
    DB1 -->|"asynchronous"| DB2

    REC --> CDN
    CDN -->|"static files"| OBJ
    CDN -->|"queries"| LBN
    LBN --> TRK
    TRK --> CACHE
    TRK --> DBT

    MONO -->|"events over private link, with backup VPN"| BUS
    BUS --> TRK
    BUS --> NOT
    NOT --> SMS
    NOT -->|"contact details, internal interface"| LB
    DB1 -.->|"old partitions and backups"| OBJ

The last pending single point of failure, the link between the data center and the cloud, is solved with a second path: in addition to the private link, an encrypted VPN tunnel over the data center's second fiber line, which comes into service automatically if the first one goes down.

Let's check the design against the availability, performance, and scalability requirements:

Requirement How the architecture responds Decision
NFR-01: shipment creation and tracking at 99.9% No single points of failure within the data center or in the cloud; automatic database failover in under 60 s; tracking does not depend on the data center. Estimate: 99.94% for both chains ADR-004, ADR-006, ADR-008
NFR-02: delivery at 99.9% from 06:00 to 22:00 and 15 min without a connection The app stores the operations and resends them with an idempotency key; the confirmation no longer depends on the SMS provider ADR-007
NFR-03: billing, reports, and back office at 99.5% mono-batch-01 and db-02, with no redundancy of their own; their degradation is accepted in order to protect what is critical ADR-004, ADR-006
NFR-04: shipments API with p95 under 300 ms Reports and tracking out of the creation path; asynchronous SMS; timeout and circuit breaker on maps ADR-004, ADR-006, ADR-007
NFR-05: tracking with p95 under 500 ms CDN for static files; cache with an expected 90% hit rate; read by key in its own store ADR-005, ADR-006
NFR-06: 200,000 shipments per day Three instances at 15 creations per second against a peak of 9; partitioning and archiving for the volume ADR-004, ADR-006
NFR-07: peaks of 50 creations and 250 queries per second Five instances of the monolith (75 creations per second); Tracking up to 8 instances; queues that level the notification peaks ADR-004, ADR-005, ADR-007
NFR-08: capacity in under 10 minutes and with no downtime Autoscaling in the cloud; in the data center, prepared instances that are switched on by schedule ADR-004
NFR-10: weekly deployment with no downtime Rolling deployment behind the load balancer ADR-004

Three honest warnings about this table:

  • It is compliance on paper. The capacities per instance and the hit rate are hypotheses. They will be validated with load tests and performance evaluation in Module 4.
  • NFR-08 is only half met. The monolith has no real elasticity as long as it stays in the data center. It is an argument for the migration of the core that ADR-002 left pending.
  • Some requirements have not been dealt with yet: security (NFR-09), in Module 3; observability (NFR-11), cost (NFR-12), and recovery (NFR-14), in Module 4. The architecture we have drawn has quite a few more pieces than RouteManager, and we still do not know how much it costs.
# ADR-008: High availability through redundancy, automatic failover, and resilience patterns

Status: Accepted
Date: 2026-06-04
Participants: Marta (architecture), Íñigo (operations), Daniel (business)

## Context
NFR-01 requires 99.9% for shipment creation and tracking. The platform
has more components than RouteManager and several pending single points
of failure: db-01, the link between the data center and the cloud, and
the unprotected external dependencies.

## Options considered
A. Keep db-01 with no standby replica and recover by hand.
B. Redundancy and automatic failover within each site.
C. Duplicate the whole platform in a second active site.

## Decision
We will adopt option B. Every critical component will have redundancy:
N+1 for stateless services and an active-passive pair for stateful
ones. We will add db-03 as a synchronous replica of db-01, with
automatic failover in under 60 s and a majority of three nodes. The
cloud services will be spread across two zones. The private link will
have a backup VPN tunnel. Every remote call will have a timeout;
external dependencies will also have a circuit breaker and a fallback.
Retries will be done in a single layer, with exponential backoff and
jitter. Before each peak season a failure drill day will be held in
pre-production.

## Consequences
Positive: estimated availability of 99.94% for the critical functions;
failures of external providers stop propagating.
Negative: more servers and more operations work; somewhat higher write
latency because of synchronous replication; reports have no redundancy.
Risks: the Zaragoza data center is still a single site; its loss will
be addressed in the disaster recovery plan.

Common Mistakes and Tips

  • Confusing redundancy with availability. Two servers in the same room, with the same power supply and the same faulty version, fail together. Always ask what the copies have in common.
  • A standby that has never been tested. It is not a standby. Failover is rehearsed regularly.
  • Calls with no timeout. It is the most frequent origin of cascading failures. No remote call without one.
  • Retrying at every layer. It multiplies the load exactly when the system is weak.
  • Retrying non-idempotent operations. It turns a network failure into duplicated data.
  • Fallbacks that saturate another component. Redirecting reports to the primary when the replica goes down moves the problem to the most critical piece.
  • Chasing nines without looking at the weak link. Improving what is already redundant does not change the result. Calculate the chain first.
  • Trusting the calculation. It assumes independent failures. Real availability is the one that is measured.
  • Tip: for every arrow in the diagram, write a sentence that begins with "if this fails, then...". The arrows for which you cannot complete it are your next incidents.

Exercises

Exercise 1

A service is made up, in series, of a managed load balancer with 99.95% availability, two application instances in parallel at 99% each, and a single database at 99.9%.

  1. Calculate the availability of the whole and the minutes of downtime per month.
  2. Does it meet a 99.9% target?
  3. You have budget for a single improvement: adding a third application instance, or giving the database a replica with automatic failover, which takes it to 99.99%. Which do you choose?

Exercise 2

State which resilience pattern corresponds to each situation:

  1. The accounting ERP has not responded for two minutes, and the Billing module stops calling it for 30 seconds instead of waiting on every attempt.
  2. The tracking page cannot load the map with the courier's position and shows the status of the shipment without a map.
  3. Bulk exports have a maximum of 5 simultaneous executions, so that they do not take up all the database connections.
  4. A thousand courier apps lose their connection at once and, when they get it back, do not all resend their operations at the same instant.

Exercise 3

A developer configures the monolith's call to the maps provider during shipment creation as follows: a 2-second timeout, up to 3 retries, and waits of 1, 2, and 4 seconds between them. The load balancer waits at most 10 seconds for the instance's response.

  1. How long can creating a shipment take in the worst case, if the provider does not respond?
  2. What does the merchant see?
  3. Propose a better design with the patterns from this lesson.

Solutions

Solution 1

  1. The two instances in parallel: 1 − 0.01² = 99.99%. In series: 0.9995 × 0.9999 × 0.999 = 0.9984, that is, 99.84%. In minutes: 43,200 × 0.0016 = about 69 minutes per month.
  2. No. The target allows 43.2 minutes.
  3. The database. With it at 99.99%, the whole comes to 0.9995 × 0.9999 × 0.9999 = 99.93%, about 30 minutes per month, and meets the target. A third instance would raise the application group from 99.99% to 99.9999%, which would barely change the total: the application was not the weak link. After the improvement, the weak link becomes the load balancer.

Solution 2

  1. Circuit breaker. After detecting the failures, the circuit opens and calls fail immediately for a while.
  2. Graceful degradation with a fallback. The essential part, the status, is offered without the non-essential part, the map.
  3. Bulkhead. A limited compartment of resources is reserved for one function, so that it cannot exhaust those of the others.
  4. Retries with backoff and jitter. Randomness spreads out over time what would otherwise be a synchronized flood.

Solution 3

  1. There are 4 attempts, the original and 3 retries, of 2 seconds each: 8 seconds. Plus the waits: 1 + 2 + 4 = 7 seconds. In total, 15 seconds.
  2. The load balancer cuts off at 10 seconds and returns an error. The merchant sees the shipment creation fail, after a 10-second wait, even though the shipment data was correct. In addition, the instance stays busy for 5 more seconds with a request nobody is waiting for anymore. With many requests in that situation, the application's threads run out: that is the cascading failure.
  3. Geocoding is not essential for registering a shipment, so it must not be able to block it:
    • Timeout of 2 seconds and at most one immediate retry, which bounds the worst case to about 4 seconds, within the load balancer's 10.
    • Fallback: if it fails, the shipment is created flagged with geocoding pending, and an asynchronous process completes it later with its own exponential backoff retries, which no longer make anyone wait.
    • Circuit breaker: after 50% failures in 20 calls, the provider is not called for 30 seconds and the fallback is applied directly. While the provider is down, shipment creation does not even lose the 2 seconds.
    • Bulkhead: a maximum of 20 simultaneous calls to the provider per instance.

Conclusion

Availability is a measure; fault tolerance and resilience are the design properties that produce it. We have learned to look for single points of failure, to choose between active-active and active-passive redundancy, and to calculate the availability of a chain: in series it multiplies and gets worse, in parallel it improves, and the result is always dominated by the weakest link. We have seen that spreading a service across zones protects against the failure of a data center, and that the resilience patterns (timeouts, retries with exponential backoff and jitter, circuit breaker, bulkheads, and graceful degradation) keep a slow dependency from dragging everything else down. With automatic database failover, the last major single point of failure within the data center disappears, and chaos engineering reminds us that none of this is true until it is tested.

This lesson brings Module 2 to an end. We started with a question: how to handle 50 shipment creations and 250 tracking queries per second without degrading. The answer has taken shape in five decisions. ADR-004 put several stateless instances behind redundant load balancers. ADR-005 placed a cache in front of tracking. ADR-006 divided the data by function, with a replica for reports and a dedicated store for Tracking, and explained why sharding is not needed. ADR-007 replaced synchronous calls with events. ADR-008 made every critical piece redundant and equipped the whole with resilience patterns. Where there was a monolith with one instance and one database, there is now a platform with an estimated availability of 99.94% for its critical functions and capacity for the peak-season spikes.

But look at the diagram again, this time with different eyes. Where there was one server behind a firewall, there are now more than a dozen components, two environments, a link that crosses from one to the other, a CDN, an event bus, several stores with recipient data, and three external providers. Every arrow is a connection someone could intercept; every box, something someone could attack; every store, a place where there is personal data to protect. We have also deliberately left several questions for later: whether internal traffic should be encrypted, what can be stored in a cache, how to keep someone from enumerating the tracking codes, which user accesses which schema. Until now, Clara has taken part in the decisions from the background. In Module 3 she moves to the foreground: the platform we have just made scalable and fault-tolerant must also be secure by design.

© Copyright 2026. All rights reserved