Lesson 13 of 17
27. Monolith vs Microservices

Practice: five levels

3 min read+10 XP

Assignments

Five levels. Do them in order. Answers are in "Solutions" at the end, so try first.

Level 1: Think (no code)

A. Monolith, modular monolith, or microservices? One line each.

  1. A 4-person startup building the first version of the bookstore.
  2. A 60-engineer company where 8 teams block each other's releases daily.
  3. A 15-engineer team with a messy monolith where every change breaks something else.
  4. A payments feature that needs separate audits and stricter deploy controls.

B. True or false? Explain in one line.

  1. A monolith can't scale beyond one server.
  2. Microservices make cross-service transactions easy.
  3. Two services that always deploy together are a sign of a wrong boundary.
  4. Each microservice should own its data.
  5. Every call between services should be synchronous so errors are visible.

Level 2: Calculate

  1. A request passes through 6 services, each available 99.9% of the time. What's the combined availability, and roughly how many minutes of failure in a 30-day month?
  2. A page calls 10 services in parallel; each is slow 1% of the time. What fraction of page loads hits at least one slow call? With 100 calls?
  3. Order history shows 50 orders; each needs a catalogue lookup taking 3 ms. How long one by one, and with one batched call?
  4. One order involves 21 calls between components. Under the two splits in 27.6, how many cross the network?
  5. The catalogue becomes slow (5 s per call). The order service gets 100 requests a second and has 200 threads. With no timeout, how many threads are busy? With a 300 ms timeout?

Level 3: Build

In Python:

  1. chain_availability(per_service, services) and p_any_slow(p, fanout).
  2. boundary_violations(imports) for a modular monolith with declared allowed dependencies.
  3. cross_calls(split) over a call graph, comparing two service splits.
  4. A Registry with heartbeats, TTL expiry and round-robin pick.
  5. place_order_sync vs place_order_async when the email service is down.

Level 4: Debug

The bookstore split out a catalogue service. During a catalogue slowdown, checkout went down too, even though checkout only needs the catalogue for book titles on the confirmation page. The order service code:

python
  1. Explain how a slow catalogue took checkout down.
  2. Fix it: name at least three changes.

Level 5: Design

The bookstore has a 60-engineer, 8-team organisation and a monolith. Search and recommendations need far more machines than the rest; payments needs separate audits; teams block each other's deploys.

Deliver:

  1. Your target architecture: what stays together, what's split out, and why.
  2. The migration plan, step by step.
  3. How services find each other and communicate (sync and async).
  4. How data is split, and how "order history with titles" and "place an order" work afterwards.
  5. What you'll measure to know the change worked.