What are the common Failure Modes in distributed systems?
Topic: microservices, Resilience. Level: Intermediate.
Answer
- **Partial failure**: some nodes/services fail while others work — the defining trait of distributed systems.
- **Network**: latency spikes, packet loss, partitions (split brain), and the "network is unreliable" fallacy.
- **Slow (grey) failures**: a service responds but slowly, exhausting caller threads — often worse than a clean crash.
- **Cascading failures**: one overloaded service drags down its callers.
- **Clock skew** and **message duplication/reordering**.
Design assuming any dependency can be slow or unavailable at any time; add timeouts, retries with backoff, circuit breakers, and bulkheads.
```java
// The #1 mistake: no timeout -> a slow dependency hangs your threads forever
var client = HttpClient.newBuilder()
.connectTimeout(Duration.ofSeconds(2)) // bound the connect
.build();
var req = HttpRequest.newBuilder(uri)
.timeout(Duration.ofSeconds(3)) // bound the response
.build();
```