What you'll learn: By the end of this lesson you will be able to write a design doc that states its decisions and alternatives, plan a load run and a failure run before touching the code, produce a counts-only report with one verdict per acceptance criterion, and read a failing row as a finding rather than an embarrassment.
Before a plane flies, someone writes the checklist, someone else flies the test, and the log records what happened, including the item that failed. The checklist is not the flight, and the log is not a promise. Each does one job, and the order matters: the checklist comes first.
The capstone works the same way. The capstone brief set the scope and seven acceptance criteria. This lesson gives you the design doc that states how the system meets them, the load and failure runs that test the claim, and the report that puts the evidence next to each criterion. The architecture decision records lesson and the lesson on reviewing designs are planned and not linked yet.
Verified against the Grafana k6 documentation, the Principles of Chaos Engineering, the AWS Fault Injection Service documentation and "Design Docs at Google" on 2026-12-02. The lab is a counting model: it shows no timings and is not a benchmark.
The core idea
The design doc says what you decided and why; the report says what happened when you tested it. A capstone needs both, and the report must be able to contradict the doc.
Three illustrations run through the lesson:
- Minimal example: one decision, a bounded queue, written with its alternatives.
- Realistic example: the ShopStream checkout slice run through the lab, in the report below.
- Failure example: a retried request that runs its work twice, which the doc did not predict and the report caught.
The design doc template
"Design Docs at Google" describes a design doc as a place to catch problems while changes are still cheap, to build agreement and to keep a record of why. It lists the usual parts: context and scope, goals and non-goals, the design itself (with trade-offs), alternatives considered, which it calls one of the most important sections, and cross-cutting concerns such as security, privacy and observability. It says a doc should not read like an implementation manual with no alternatives or trade-offs.
The capstone version keeps those parts and adds the two evidence plans:
# Design doc: ShopStream checkout slice
1. Context and scope what exists, what this builds, link to the brief
2. Goals and non-goals the brief's list, with a reason per non-goal
3. Requirements F1 to F5, N1 to N5, and acceptance criteria AC-1 to AC-7
4. Design overview system-context figure, the request path, state kept
5. Decisions one table per decision: options, choice, cost, when it is wrong
6. Cross-cutting concerns failure handling, idempotency, observability, security
7. Load plan profiles, the question each answers, criteria written first
8. Failure plan hypotheses, blast radius, stop condition, owner
9. Risks and open questions what could be wrong and who finds out
10. Results and findings filled in after the runs, with the report attached
Sections 7 and 8 are written before the code. Section 10 is written last and is allowed to say the design was wrong.
Minimal example. A decision, as it would appear in section 5:
| Option | Gain | Cost | Wrong when |
|---|---|---|---|
| Unbounded queue | Never rejects an order | Memory and waiting time grow without limit | Load can exceed capacity for long |
| Bounded queue (limit 200, illustrative) | Rejects early with a 503; latency stays bounded | Some shoppers are turned away | The limit is far below real bursts |
Choice: bounded, because RFC 9110 gives 503 a defined meaning ("currently unable to handle the request") and a client can retry later. The consequence goes in section 9: a retry storm is possible, so retries need backoff (see load shedding and retry storms).
section 5"] --> C["Testable claim
acceptance criterion"] C --> P["Plan
sections 7 and 8"] P --> R["Run
counts only"] R --> V{"Criterion met?"} V -->|yes| E["Evidence
section 10"] V -->|no| F["Finding"] F --> D
Figure 1. The loop from decision to evidence. How to read this: a failed criterion loops back to the decision, not forward to a better-looking number. The finding changes the design, and the next run tests the change.
Planning the load run
The k6 documentation names the test types by the question each asks: a load test assesses performance "under expected normal conditions", a stress test how a system performs "at its limits when load exceeds the expected average", a soak test reliability "over extended periods", and a spike test survival of "sudden, short, and massive increases". It also says that no single type removes all risk and advises starting with a smoke test. The load, stress and soak testing lesson covers these in depth.
The capstone needs two shapes:
- Expected peak (a load test): a constant arrival rate of 58 per tick for 120 ticks. Question: is the expected peak accepted in full? Criterion AC-1.
- Overload (a stress test): a ramp from 20 to 200 per tick, then 60 quiet ticks. Question: is excess load rejected early, and does the queue drain? Criterion AC-2.
Both are open workloads: in k6's words, "VUs arrive independently of iteration completion". In a closed model the target's response time can reduce the arrival rate, which k6 notes is known in some testing literature as coordinated omission. An open workload keeps arriving while the service falls behind, which is what a real sale does.
Pick the profile from the forecast, not from the tool: capacity planning shows how headroom and failure domains turn a forecast into a fleet size and so into the thresholds you test against.
Planning the failure run
A failure plan is a set of experiments. The Principles of Chaos Engineering describe four steps: define steady state as a measurable output, hypothesise that it continues in the control and experimental groups, introduce real-world variables, and try to disprove the hypothesis. AWS gives the hypothesis template: "If {fault injection action} is performed, the {business or technical metric impact} should not exceed {value}."
The capstone writes four hypotheses, all on the price lookup that checkout depends on:
| Id | Hypothesis (illustrative thresholds) | Fault | Limit |
|---|---|---|---|
| AC-3 | If 50% of lookups return an error, at least 99% of checkouts are still answered | Error on 50% | none |
| AC-4 | If the lookup is down, at most 10 calls are affected | Error on 100% | cap of 10 |
| AC-5 | If the lookup is down, the experiment stops within 40 requests | Error on 100% | stop condition |
| AC-6 | If 30% of responses are dropped, no request runs its work twice | Dropped response on 30% | none |
The two limits are the blast radius. The Principles make the engineer responsible for keeping the fallout of an experiment small. AWS defines a stop condition as a mechanism that stops an experiment when a threshold, defined as a CloudWatch alarm, is reached, and says a stopped experiment cannot be resumed. Its planning guidance says to start in a test environment, start with small experiments and have monitoring and alerting in place first. The chaos engineering lesson explains these in depth.
Build it: the capstone report lab
The lab is examples/spring-labs/labs/capstone-load-and-failure-report (Spring Boot 4.1.2, Java 25; MockMvc for the web layer, no Docker, no network, no database). It does not copy the earlier labs. It depends on them:
dependencies {
// The capstone report reuses two published labs instead of copying them.
implementation(project(":labs:load-stress-soak-model"))
implementation(project(":labs:chaos-fault-injection"))
implementation("org.springframework.boot:spring-boot-starter-webmvc")
testImplementation("org.springframework.boot:spring-boot-starter-webmvc-test")
}
From load-stress-soak-model it uses OrderController (a POST /orders that answers 202 or 503), OrderGate (capacity per tick and a queue limit), ConnectionPool and LoadProfile. From chaos-fault-injection it uses Experiment, Client and the fault injector. The only new pieces are a short MockMvc driver (the load lab's own generator is in its test sources), the Criterion and AcceptanceReport classes, and the run that fills the table in.
Figure 2. How the lab is assembled. How to read this: the capstone run is the only new code. It borrows the service model and the fault harness, and only counts flow into the table, never timings.
Each criterion is a small record: an id, a requirement, a threshold, the measured value and a verdict. The last two rows of the run show the two cases the model has to handle, a check that can fail and a criterion the model cannot measure:
list.add(Criterion.check("AC-6", "A retried request runs its work once", "0 duplicate executions",
duplicates + " duplicate executions", duplicates == 0));
list.add(Criterion.notMeasured("AC-7", "Checkout p95 on the deployed stack", "set in the design doc",
"needs a real deployment"));
The service numbers are the lab's own illustrative assumptions: 80 orders served per tick, a queue limit of 200 and a pool of 1,000. A tick stands for one illustrative second; the peak of 58 per tick is the ShopStream course's illustrative figure. The failure experiments use the chaos lab's modelled time, in which nothing sleeps. Run it from examples/spring-labs with ./gradlew :labs:capstone-load-and-failure-report:test: eight tests pass, including a comparison with the golden file and a check that two runs print the same text.
Expected output, captured from a real run (two load runs, five failure experiments, the acceptance table):
# Capstone load and failure-injection report. Counts only: this is not a benchmark.
# Illustrative service: 80 orders per tick, queue limit 200, pool 1000; a tick stands for one illustrative second.
load run ticks sent 202 503 completed peakQ endQ firstReject
peak 120 6960 6960 0 6960 58 0 -
overload 160 11000 6920 4080 6920 200 0 46
failure experiment injected answered fallback dep calls hypothesis aborted at
catalogue errors 50%, naive 109 45% 0 91 BREACHED -
catalogue errors 50%, guarded 158 100% 45 155 holds -
catalogue down, naive, cap 10 10 95% 0 190 BREACHED -
catalogue down, naive, stop condition 20 90% 0 180 BREACHED request 20
dropped responses 30%, retrying 80 98% 0 276 BREACHED -
id requirement threshold measured verdict
AC-1 Expected peak is accepted 0 rejected at 58 per tick 0 rejected of 6960 PASS
AC-2 Overload is rejected early and drains peakQ <= 200 and endQ = 0 peakQ 200, endQ 0 PASS
AC-3 Catalogue errors do not stop checkout answered at least 99% answered 100%, fallback 45 PASS
AC-4 Blast radius is capped injected at most 10 injected 10 PASS
AC-5 Stop condition aborts the fault aborted by request 40 aborted at request 20 PASS
AC-6 A retried request runs its work once 0 duplicate executions 76 duplicate executions FAIL
AC-7 Checkout p95 on the deployed stack set in the design doc needs a real deployment NOT_MEASURED
5 PASS, 1 FAIL, 1 NOT_MEASURED of 7 criteria.
How to read it:
- Peak. 120 ticks of 58 is 6,960 requests; all are accepted, nothing is rejected, and the queue never holds more than 58. AC-1 passes.
- Overload. The ramp sends 11,000 requests. The first 503 arrives at tick 46, the queue reaches its limit of 200, 6,920 are accepted and 4,080 rejected. After the 60 quiet ticks the queue is empty and every accepted order was completed (6,920 completed). AC-2 passes: overload was refused early instead of queued without limit.
- Catalogue errors. These are the chaos lab's rows for 50% errors. The naive client answers 45% and breaches the hypothesis; the guarded client (a 100 ms timeout, one retry, a stale-copy fallback) answers 100% with 45 fallbacks and holds. The price is extra load: 155 dependency calls for 200 requests. AC-3 passes.
- Cap and stop. With a cap of 10 only 10 calls are affected; with the stop condition the fault is switched off after the first window of 20 requests. Both rows say BREACHED because the naive client has no protection; the limits decide how much the finding cost. AC-4 and AC-5 pass.
- Dropped responses. The dependency ran 276 times for 200 requests: 76 duplicate executions. AC-6 fails. This is a finding, not a bug in the report.
- AC-7 is NOT_MEASURED. The table says so instead of inventing a latency.
Figure 3. The life of a criterion. How to read this: the threshold is fixed before the run, which is the only reason a pass means anything. A fail is not an end state; it leads to a finding and a rerun.
The failure example in detail
AC-6 fails for a reason Figure 4 shows. A response is dropped after the work happened. The client cannot tell that from a failure, so it retries.
Figure 4. Why AC-6 fails. How to read this: from the caller's side attempt 1 failed; from the dependency's side it succeeded. A key sent with both attempts lets the dependency answer the second from the first instead of repeating it, which is the fix in the idempotency keys lesson.
Writing the findings
The report ends with findings. Each one names the criterion, the evidence, the cause, the change and the new threshold. For AC-6: "76 duplicate executions for 200 requests with 30% dropped responses and two retries; the model has no idempotency key; add one and rerun; target 0." The finding goes back to section 5 of the doc, because the decision "retry on timeout" now has a cost that the doc must carry.
Trade-offs
| Choice | Gain | Cost | Wrong when |
|---|---|---|---|
| Reuse the published labs | Less code, one tested model | Their limits (fixed seed, fixed 200 requests) apply | You need a scenario they cannot express |
| Counts, not timings | Identical on every machine | No latency or saturation | You claim a performance number |
| Fixed thresholds before the run | A pass means something | You may pick badly | You change them after seeing the data |
| One failure fault at a time | Clear cause | Misses combined failures | Real incidents are combinations |
| Deploy and measure | Real timings | Cost and noise | You cannot read or repeat the result |
In practice: the report for a checkout slice
This is a realistic scenario, not a case history.
This is an educational scenario on ShopStream; nothing in it describes a real team. The 58 per second is the shared illustrative figure; every other number is the lab's.
The situation
A learner has the brief, a design doc with sections 1 to 6 filled in, and a working slice. Sections 7 and 8 are empty. The demo is in three days.
Starting architecture
One checkout service with an order gate, a catalogue lookup and a price cache, as in Figure 1 of the brief.
Options considered
| Option | Gain | Cost | Risk |
|---|---|---|---|
| A. Run a load tool and quote its numbers | Looks real | Needs a deployment; numbers depend on the machine | Numbers not repeatable or defended |
| B. Reuse the counting labs and report counts | Repeatable; every row traceable | No timings | Mistaken for a benchmark |
| C. Skip failure testing | Saves a day | Resilience claims unproved | The first failure is the demo |
The decision
Option B, with AC-7 marked "not measured" and a one-line plan to measure it on a deployment later. Thresholds are written into sections 7 and 8 before the first run.
Rollout and verification
Run the tests; confirm the golden file matches; read the table. Five rows pass, AC-6 fails and AC-7 is unmeasured. Write the AC-6 finding, add an idempotency key to the design, update section 5 and rerun. The goal is a table where AC-6 reports 0 duplicates and the doc says why.
The 2 a.m. failure
Months later, in a deployed version, the payment provider times out under load and the client retries. Duplicate orders appear even though the lab's AC-6 was fixed, because the key was stored only in memory and the service restarted between attempts. First checks: where the key is stored, its lifetime and whether it survives a restart. Mitigation: store keys durably with the order. The lesson for the report: the lab proved the logic, not the storage; section 9 should have listed "key durability" as an open risk.
Architect's notes
- Write the load and failure plans before the build. They are part of the design.
- Let the report contradict the doc. A report that cannot disagree is a description.
- Keep model and measurement apart. Label counts as counts, and mark what needs a deployment.
- Reuse tested harnesses. A new fault injector adds new bugs to the evidence.
- Name an owner per finding. An unowned finding is a future incident.
Common mistakes
- Writing the doc after the code. It becomes a description of what was built.
- An alternatives section with one option. There was no decision.
- A load profile with no question. Nobody can say what its result means.
- A fault with no cap or stop condition. The experiment is the incident.
- Hiding the failed row. The failed row is the most useful one.
- Quoting counts as timings. A tick is not a second.
Key takeaways
- The design doc records decisions and alternatives; the report records evidence.
- Plans for the load and failure runs belong in the doc before the code.
- Use an open workload to model a surge that does not wait for the service.
- A failure experiment has a hypothesis, a cap and a stop condition.
- A counting model can prove logic, not latency; say which criteria it cannot measure.
- A failing row becomes a finding, a design change and a rerun.
Practice exercises
Exercise 1 (30 min). Fill in sections 5 and 7 of the template for the order gate: two alternatives, a choice, a profile and a threshold written before a run.
Exercise 2 (45 min). Change PEAK_PER_TICK to 90 in the lab and predict AC-1 before you run it. Restore the value afterwards.
Exercise 3 (1 hour). Add an in-memory idempotency-key set in front of the dependency so AC-6 reports 0 duplicates. What does the test prove, and what does it not (see the 2 a.m. failure)?
Exercise 4 (45 min). Write a spike profile and a criterion for it, with the threshold fixed first.
Related reading
- Capstone Brief: A Scoped Distributed System: the scope, requirements and rubric.
- Load, Stress and Soak Testing: the load lab this one reuses.
- Chaos Engineering: the fault-injection lab this one reuses.
- Capacity Planning: choosing thresholds for a real deployment.
- Idempotency Keys and Safe Retries: the fix for AC-6.
- ShopStream Stage 9: Surviving Failure Without Losing Orders: the resilience plan the failure run tests.
- ShopStream Stage 10: Secure, Observable and Ready to Run: the operations view of the same system.
Official documentation
- Grafana k6: test types: load, stress, soak and spike definitions.
- Grafana k6: open and closed models: arrival independent of completion.
- Principles of Chaos Engineering: the experiment steps and blast radius.
- AWS Fault Injection Service: planning: the hypothesis template and starting small.
- AWS Fault Injection Service: stop conditions.
- Design Docs at Google: the parts of a design doc.