Failure Modeling

After the happy path works: what if payment fails, the request repeats, the database is down, the browser closes. Failure injected on purpose.

Failure Modeling

The basic path works. Now ask, step by step, what happens if the payment fails, the database is down, the request repeats, or the user closes the browser — and turn each answer into a state the system can be in and a test that puts it there.

Q · Checkout works when everything goes right. How do you find out, systematically rather than by accident, what happens when something goes wrong?
What If Payment Fails?
▶ lab

"Payment failed" is not one event. The card can be declined, the provider can time out, the browser can close after the charge, the confirmation can arrive twice. The question that sorts them is: who says the payment succeeded, and how does my system find out?

Q · The frontend says "Payment failed". What actually happened, which system knows, and what should the order be marked as?
Duplicate Requests

A payment must not happen twice, and the double click, the browser retry, the webhook redelivery and your own retry loop all make the same request twice. Idempotency is the name for the answer; the lesson is discovering the question.

Q · The same checkout request arrives twice. What should happen, where is it decided, and how do you know it works?
Partial Failure

The payment succeeded and the backend crashed before the order was written. Two things that were supposed to be one thing happened separately, and the system is now in a state nobody designed. The move is to find every such gap and decide what fills it.

Q · Checkout does several things across several systems. What happens if it stops half-way, and how do you find the gaps before a customer does?
Failure Injection
▶ lab

Once the store works, make it fail on purpose: a payment that times out, a product that runs out during checkout, a checkout submitted twice, a database that is not there. Each injection turns a failure you reasoned about into one you observed.

Q · You have a failure model on paper. How do you find out whether the system actually does what the paper says?
Failure-First Questions

Five questions to ask of any design, at any boundary: what if it fails, what if it is slow, what if it repeats, what if it arrives out of order, what if it is unavailable. They are dull, they are the same every time, and that is why they work.

Q · You are looking at a design you have never seen — a chat app, an upload service, a dashboard. What do you ask to find its failure modes without knowing the domain?