Module 94: Distributed Systems

Lesson 4 of 5 · 15–25 minutes

Failures

🏠The everyday picture

A phone call drops mid-sentence. Did the other person hear your last words? You can't tell. Ringing back and repeating yourself is safe only if repeating doesn't cause harm.

📘What it really is

🖱️Try it

Add idempotency keys to your POST /v1/bookings and payment-creation calls: store the key and result, and return the stored result on repeats. Add timeouts and backoff-with-jitter retries to your payment gateway adapter. Wrap the email adapter in a simple circuit breaker (for example with the opossum library). In staging, make the payment gateway (or a fake) slow and failing, and check the app stays responsive and nothing is double-charged.

✅Quick check

After a timeout, why is it unsafe to simply retry a payment?

Show the answer

The first request may have succeeded with the reply lost; without an idempotency key, the retry could charge twice.

What does a circuit breaker do?

Show the answer

After repeated failures, it stops calling a service for a while and fails fast, protecting both sides.

← PreviousConsistency
ProLearners Assist