🎓 A1Learner
🔍
0 of 47 lessons completed

Single Points of Failure

A single point of failure is the one part of a system whose failure stops the whole system. A part with only one copy is a single point of failure.

Copy counts on one request path

The path has 4 parts and each part lists its copy count. The part with 1 copy is marked.

parts = [
    ("app server", 2),
    ("database", 1),
    ("cache", 3),
    ("load balancer", 2),
]
for name, copies in parts:
    mark = " <- can stop the whole system" if copies == 1 else ""
    print(f"{name}: {copies}{mark}")

Counting the parts at risk

Only the parts with a copy count of 1 can stop the whole system. This path has exactly one such part.

parts = [
    ("app server", 2),
    ("database", 1),
    ("cache", 3),
    ("load balancer", 2),
]
risky = [name for name, copies in parts if copies == 1]
print("parts with one copy:", len(risky))
print("part:", risky[0])

A request stops at the single copy

The request passes each part in order until it reaches the part that is down. It never gets past that part.

path = ["load balancer", "app server", "cache", "database"]
down = "database"
for part in path:
    if part == down:
        print("stopped at:", part)
        break
    print("passed:", part)

Example

parts = [
    ("app server", 2),
    ("database", 1),
    ("cache", 3),
    ("load balancer", 2),
]
for name, copies in parts:
    mark = " <- single point of failure" if copies == 1 else ""
    print(f"{name}: {copies}{mark}")
risky = [name for name, copies in parts if copies == 1]
print("single points of failure:", len(risky))

Key points

  • Single point of failure: The one part whose failure stops the whole system.
  • Copy: One running instance of a part, so two copies means the part runs in two places.
  • Part with copies: A part with two or more copies keeps working when one copy stops.
  • Part with one copy: A part with exactly 1 copy stops the whole request path when it fails.
  • Finding them: List the parts on a request path and check the copy count of each one.

In this example, the audit lists 4 parts and their copy counts of 2, 1, 3 and 2. Only the database has 1 copy, so the path has exactly 1 single point of failure.

Note

A single point of failure is a fact about copy counts, and it can be found before anything breaks.

Try it Yourself

Edit the code, then press Run.

Running is simulated

Exercise

A request path has parts with copy counts of 2, 1, 3 and 2. Which part is the single point of failure?