在大规模环境下,故障是不可避免的 — 服务器崩溃、网络中断、依赖项变得不可用。为故障而设计意味着构建能够容忍并从故障中优雅地恢复的系统,而不是假设一切都正常工作。这对于可靠系统至关重要。
为故障而设计(心态)
text
ASSUME things WILL fail → at scale, failures are NORMAL, not exceptional:
→ servers crash, networks partition, disks fail, dependencies go down, traffic spikes
→ design systems to EXPECT and HANDLE failures gracefully (not assume everything works)
→ "everything fails all the time" → build resilience in.
韧性技术
text
✓ REDUNDANCY → multiple instances, no single point of failure (failover to healthy ones)
✓ RETRIES (with backoff) → retry transient failures (with exponential backoff + jitter to
avoid overwhelming a recovering service)
✓ TIMEOUTS → don't wait forever for a failing dependency (fail fast)
✓ CIRCUIT BREAKERS → stop calling a failing service temporarily (prevent cascading failures;
give it time to recover) → fail fast and fall back
✓ GRACEFUL DEGRADATION → reduced functionality vs total failure (e.g. show cached/partial
data if a service is down)
✓ FALLBACKS → a default/alternative when something fails
✓ BULKHEADS / isolation → contain failures (one part failing doesn't sink everything)
