Skip to content
Tech Atlas, home
Search
Esc
  • All roadmapsBrowse every learning path
  • ExploreFind a technology area
  • ProjectsGuided projects and builds
  • My AtlasYour learning dashboard
Lesson 3 of 5 · Concept · 20 min · revision 1

Style characteristics and the price of distribution

Rate styles as trade-offs with conditions instead of star ratings, measure the cost of one network hop, and use a small model to see how failures add up along a chain of synchronous calls, and why the answer depends on its assumptions.

Contentsand lesson path

What you will learn

  • Rate candidate styles against a system's prioritized quality attributes and constraints, including team size and operational maturity.

Prerequisites: Quality Attributes & Trade-offs

01. Why it matters

Comparisons of architecture styles often arrive as tables of stars: five for scalability, two for simplicity. Such tables are easy to remember and easy to misuse, because every rating hides a condition. "Microservices are easy to deploy" is true for an organisation with automated pipelines and teams that need to release separately; for a team of four that deploys by hand once a month, the same style means more manual releases, not easier ones.

This lesson replaces stars with conditional claims: style S gives characteristic C when X holds, and costs Y. It then looks at the largest Y of all, the price a system pays every time a call crosses a network. You will measure one hop on your own machine and run a small model of failures along a call chain. The characteristics themselves come from the drivers you learned to state in testable scenarios.

02. Characteristics as trade-offs with conditions

Here are the characteristics that most often decide a style, each written as a condition rather than a score.

  • Deployability. Separate deployment units let teams release without waiting for each other, if each unit has its own automated pipeline and the units do not have to change together. With manual releases, or with features that always touch three units at once, more units means more coordination.
  • Elasticity. Separate units can scale separately, which pays off when parts have very different load profiles. If everything rises and falls together, more copies of one deployable scale just as well. Scaling out has limits of its own, such as a shared database and contention, so no style scales without bound.
  • Fault isolation. A failing part stays contained only if the parts that depend on it can carry on without it, for example because the call is asynchronous or has a fallback. A synchronous call with no timeout carries the failure straight across the boundary.
  • Testability. One deployable can be tested end to end in a single process. Distributed parts are easier to test alone and harder to test together, so they need contract tests and good test environments.
  • Performance. An in-process call costs nanoseconds; a network call costs far more and varies more. A design that makes many fine-grained calls feels this first.
  • Simplicity. Every deployment unit adds a pipeline, dashboards, alerts, versions to keep compatible and something to be on call for. A small team pays this per unit, per person.
  • Cost. Distributed units each need a minimum footprint, plus brokers, gateways and observability tooling, and many clouds bill traffic between zones. Pay-per-use platforms invert this for idle workloads and can cost more for steady heavy ones.

Two inputs move almost every rating: team size and operational maturity. A rule of thumb from Conway's law (1968), a heuristic rather than a law of nature, is that systems tend to mirror the communication structure of the teams that build them. One team gains little from boundaries that only another team would need. Operational maturity is the list of things each unit needs to run: automated build and deploy, monitoring and alerting, tracing across units, an on-call rota and a tested way to roll back. Martin Fowler calls the extra cost and risk of running many services the microservice premium and argues for starting most new products as a monolith, then splitting where real boundaries and real needs appear.

03. The price of distribution: eight fallacies

In 1994 L Peter Deutsch, then at Sun Microsystems, wrote down seven assumptions that people new to distributed systems tend to make, and that later hurt them; around 1997 James Gosling added an eighth. Together they are known as the fallacies of distributed computing. Read them as a price list. A single-deployable style pays almost none of these prices for calls between its parts; a distributed style pays most of them at every boundary it adds.

Text · each fallacy and what it costs a distributed style
Fallacy                       What it costs at every boundary
----------------------------  -----------------------------------------------------
1 The network is reliable     calls fail or vanish: timeouts, safe retries, and a
                              plan for "did it happen or not?"
2 Latency is zero             every hop adds time and variance: coarse calls, not
                              chatty ones
3 Bandwidth is infinite       big payloads and fan-out compete: pass references,
                              page results
4 The network is secure       any hop can be observed or spoofed: authenticate and
                              authorise each call, encrypt in transit
5 Topology does not change    instances move and scale: find services by discovery,
                              not fixed addresses
6 There is one administrator  parts are run by other teams or firms: version
                              contracts, watch dependencies you do not control
7 Transport cost is zero      serialisation uses CPU, and traffic between zones and
                              regions is often billed
8 The network is homogeneous  mixed protocols, versions and clients: agree on
                              interoperable formats

04. Measure one hop

Fallacy 2 is easy to see on your own machine. The script below calls the same tiny function in-process and through an HTTP server on 127.0.0.1, the loopback interface, and prints the median time per call. It uses only the Python 3.12 standard library and port 18431.

Python · hop_cost.py
"""hop_cost.py: the same tiny function, called in-process and over loopback HTTP."""
import statistics
import threading
import time
import urllib.request
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer


def price(item: str) -> int:
    return len(item) * 3


class PriceHandler(BaseHTTPRequestHandler):
    def do_GET(self) -> None:
        body = str(price(self.path.lstrip("/"))).encode()
        self.send_response(200)
        self.send_header("Content-Length", str(len(body)))
        self.end_headers()
        self.wfile.write(body)

    def log_message(self, *args) -> None:  # keep the terminal quiet
        pass


server = ThreadingHTTPServer(("127.0.0.1", 18431), PriceHandler)
threading.Thread(target=server.serve_forever, daemon=True).start()
opener = urllib.request.build_opener(urllib.request.ProxyHandler({}))  # no proxy


def median_us(call, n: int) -> float:
    samples = []
    for _ in range(n):
        start = time.perf_counter_ns()
        call()
        samples.append(time.perf_counter_ns() - start)
    return statistics.median(samples) / 1000


local = median_us(lambda: price("tea"), 20_000)
remote = median_us(lambda: opener.open("http://127.0.0.1:18431/tea").read(), 2_000)
print(f"in-process call: {local:9.2f} µs (median of 20,000)")
print(f"loopback HTTP:   {remote:9.2f} µs (median of 2,000)")
print(f"ratio:           about {remote / local:,.0f} times")
server.shutdown()
Terminal
python3 hop_cost.py
Illustrative output (one run on a desktop PC; your numbers will differ)
in-process call:      0.16 µs (median of 20,000)
loopback HTTP:      631.91 µs (median of 2,000)
ratio:           about 3,999 times

Expect a gap of roughly three orders of magnitude or more; the exact numbers depend on your machine. This loopback call opens a new connection every time and runs a slow pure-Python server, so a production stack with reused connections may be faster per call. It also leaves things out: no physical network, no distance, no TLS, no load balancer, and no other traffic. And a median hides the slow calls that a busy network produces.

Treat the number as a measure of software overhead on one host, not as a budget for a real hop. Measure on the real path, at the percentile your scenario names. If a cascading failure is what you fear, the slow tail matters more than the median.

05. How failures add up along a chain

Fallacy 1 has a structural consequence. If a request must wait for several services in turn, it succeeds only when all of them succeed. The script below is a model, not a measurement: every call succeeds 99.9% of the time, and the second table compares two assumptions about when the 0.1% of failures happen. It is seeded, so it prints the same numbers every time.

Python · chain_model.py
"""chain_model.py: how per-call failures add up along a synchronous chain.

A model, not a measurement. Every call succeeds 99.9% of the time; the second
table shows that what a retry buys depends on how failures are spread in time.
"""
import random

P_FAIL = 0.001  # each call fails 0.1% of the time
REQUESTS = 300_000
rng = random.Random(7)


def chain_ok(hops: int) -> bool:
    return all(rng.random() >= P_FAIL for _ in range(hops))


print("1) services the request waits for, failures independent")
print("   hops  simulated  formula (1-p)^hops")
for hops in (1, 3, 6, 12):
    ok = sum(chain_ok(hops) for _ in range(REQUESTS)) / REQUESTS
    print(f"   {hops:4}  {ok:9.3%}  {(1 - P_FAIL) ** hops:9.3%}")

HOPS = 6
DAY = 86_400  # seconds
OUTAGE = 86  # one 86 s outage per service per day: also 0.1% of the time
RETRY_AFTER = 0.2  # seconds


def independent(rows: int) -> tuple[float, float]:
    """Each call fails at random; a retry is a fresh, independent draw."""
    plain = retried = 0
    for _ in range(rows):
        draws = [(rng.random(), rng.random()) for _ in range(HOPS)]
        plain += all(first >= P_FAIL for first, _ in draws)
        retried += all(first >= P_FAIL or again >= P_FAIL for first, again in draws)
    return plain / rows, retried / rows


def outages(rows: int) -> tuple[float, float]:
    """Each service is down for one 86 s window a day; a retry 0.2 s later."""
    plain = retried = 0
    for _ in range(rows // 100):  # a new model day for every 100 requests
        starts = [rng.uniform(0, DAY - OUTAGE) for _ in range(HOPS)]
        for _ in range(100):
            t = rng.uniform(0, DAY)
            down_now = [s <= t < s + OUTAGE for s in starts]
            later = t + RETRY_AFTER
            down_later = [s <= later < s + OUTAGE for s in starts]
            plain += not any(down_now)
            retried += not any(a and b for a, b in zip(down_now, down_later))
    return plain / rows, retried / rows


print(f"\n2) {HOPS} services in a chain, one retry {RETRY_AFTER * 1000:.0f} ms later")
print("   failure pattern             no retry  one retry")
models = {"independent, per call": independent, "one 86 s outage a day": outages}
for label, model in models.items():
    plain, retried = model(REQUESTS)
    print(f"   {label:<26}{plain:9.3%}{retried:11.3%}")
Terminal
python3 chain_model.py
Expected output (seeded, so it matches exactly)
1) services the request waits for, failures independent
   hops  simulated  formula (1-p)^hops
      1    99.895%    99.900%
      3    99.702%    99.700%
      6    99.384%    99.401%
     12    98.797%    98.807%

2) 6 services in a chain, one retry 200 ms later
   failure pattern             no retry  one retry
   independent, per call       99.412%   100.000%
   one 86 s outage a day       99.388%    99.388%

The first table follows the formula: with independent failures, the success rate of a chain is the product of the rates of its calls, so twelve calls at 99.9% each give about 98.8%. In a monolith those twelve steps would be function calls that do not fail on their own. The same arithmetic explains why fan-out makes rare slowness common. The design lever is the number of calls a request must wait for: a service that receives an event and does its work later is not in the product, as long as the user does not need its answer.

The second table is the warning. With failures spread at random, one retry makes each call fail only when two independent draws fail, and the chain rounds to 100.000% (about six failures in a million requests). With the same 0.1% of failure time arriving as one 86-second outage per service per day, a retry 0.2 s later almost always lands inside the same outage, and it buys almost nothing. Real failures are often of the second kind: deploys, overloaded databases, expired certificates, a dependency that several services share. A model is only as good as its assumptions, so state them next to every number you quote.

06. Check your understanding

Practice check · 3 questions

Conditions and costs

Three claims about distributed designs. Pick the best answer for each.

Q1. A shop runs its monolith on 2 instances. It is split into 8 services, and each service runs at least 2 instances so that one can fail. Traffic and total CPU work stay the same. Which cost is most likely to rise?
Q2. A chain model with independent failures predicts that one retry per call lifts a six-service chain from about 99.4% to almost 100%. In production, most failures are whole-service outages lasting a few minutes, and the retry is sent 200 ms after a failure. What should you expect?
Q3. `hop_cost.py` shows a median of about 500 µs per loopback call on your laptop. A colleague plans a five-service chain in production and budgets 5 × 500 µs for the network. What is wrong with that budget?
Practice only: not graded, not saved, not evidence.

07. Apply it

Turn your notes on the two practice briefs into conditional claims.

  1. Pick the four characteristics that matter most for each brief.
  2. For every candidate style, write one line per characteristic in the form gives C when X; costs Y. Use what each brief says about team size, release habits and on-call to decide whether X holds.
  3. For the enterprise brief, write down how many calls a typical user request would wait for in each candidate style, and which of the eight fallacies you would pay for at each boundary.

In lesson 4 you will turn these claims into scores and a recommendation.

08. Review prompt

Without looking back: state the condition under which separate deployment units improve deployability, elasticity and fault isolation, and what each costs. List the eight fallacies of distributed computing and one design consequence of each. Explain why the success rate of a synchronous chain falls with its length, how moving work off the synchronous path changes that, and why the benefit of a retry depends on whether failures are independent.

References

Your progress

Reading state

Sign in to save that you finished reading this lesson.

Sign in to mark reading complete

Prove this skill

6 questions · about 5 minutes · scored automatically. Marking a lesson as read never demonstrates a skill.
Take the skill check