Microservices Resilience Patterns
| name | how does it work? | description | links |
|---|---|---|---|
| Retry | repeats failed executions | Many faults are transient and may self-correct after a short delay. | overview, documentation, Spring |
| Circuit Breaker | temporary blocks possible failures | When a system is seriously struggling, failing fast is better than making clients wait. | overview, documentation, Feign, Spring |
| Rate Limiter | limits executions/period | Limit the rate of incoming requests. | overview, documentation, Feign, Spring |
| Time Limiter | limits duration of execution | Beyond a certain wait interval, a successful result is unlikely. | documentation, Spring |
| Bulkhead | limits concurrent executions | Resources are isolated into pools so that if one fails, the others will continue working. | overview, documentation, Spring |
| Cache | memorizes a successful result | Some proportion of requests may be similar. | documentation |
| Fallback | provides an alternative result for failures | Things will still fail - plan what you will do when that happens. | Try::recover, Spring, Feign |
<dependency>
<groupId>io.github.resilience4j</groupId>
<artifactId>resilience4j-circuitbreaker</artifactId>
<version>${resilience4jVersion}</version>
</dependency><dependency>
<groupId>io.github.resilience4j</groupId>
<artifactId>resilience4j-ratelimiter</artifactId>
<version>${resilience4jVersion}</version>
</dependency><dependency>
<groupId>io.github.resilience4j</groupId>
<artifactId>resilience4j-retry</artifactId>
<version>${resilience4jVersion}</version>
</dependency><dependency>
<groupId>io.github.resilience4j</groupId>
<artifactId>resilience4j-bulkhead</artifactId>
<version>${resilience4jVersion}</version>
</dependency>mvn test -Dtest=HelloResilienceApplicationTests#testCircuitBreakermvn test -Dtest=HelloResilienceApplicationTests#testRetrymvn test -Dtest=HelloResilienceApplicationTests#testRateLimitingmvn test -Dtest=HelloResilienceApplicationTests#testBulkheadhttps://github.com/resilience4j/resilience4j-spring-boot3-demo