Part 09 · Distributed Systems

8 lab failure và recovery

Dùng fault injection có kiểm soát, invariant và telemetry; không chỉ tắt service rồi nhìn exception.

Lab 01 · Unknown outcome

Payment endpoint commit rồi delay/drop response. Client timeout và retry cùng idempotency key; assert một charge, query operation status và reconciliation sửa request stuck.

Lab 02 · Retry amplification

Ba tầng mỗi tầng retry 3 lần, đo downstream attempts/latency. Chuyển ownership về một tầng, deadline propagation, jitter và retry budget; so sánh successful throughput.

Lab 03 · Circuit/bulkhead/load shedding

Inject downstream latency. Đo pool saturation; thêm per-dependency bulkhead, breaker half-open giới hạn probe và bounded queue/rejection. Kiểm tra fallback không nói dối business.

Lab 04 · Boundary comparison

Xây Order/Inventory dạng modular monolith rồi tách sync services. Ghi coupling, transaction, deploy, test và on-call cost; quyết định có giữ tách hay quay lại module.

Lab 05 · Replication lag UX

Giả lập replica/read-model delay. Tạo operation PENDING, session version token hoặc primary read; chứng minh user không thấy state quay lùi.

Lab 06 · Saga failure matrix

Order–Payment–Inventory orchestration với persisted state. Inject reserve fail, payment timeout, refund fail và duplicate event; thêm manual recovery và audit transition.

Lab 07 · Outbox/inbox

Business row + outbox cùng transaction, relay crash sau publish trước mark-sent, consumer inbox unique. Đo oldest unpublished age, cleanup và reconciliation missing effects.

Lab 08 · Cascading-failure game day

Load test + downstream saturation + retry storm. Lưu dashboards/traces/thread/pool metrics; áp shedding/cancellation, viết incident timeline, recovery và postmortem action.

Rubric

MứcTiêu chí
1Flow chạy và có timeout/error.
2Có duplicate, overload, durable state và metrics.
3 · SeniorChứng minh invariant, recovery, rollout và operational trade-off.