# A Map of the Patterns — Rate Limiting, Circuit Breakers & Resilience Patterns

Source: https://www.skillbyai.com/en/resilience-patterns/f-map

> Group resilience patterns by what they protect and where they run.

## Protect yourself, protect others

Resilience patterns fall into a few families. **Patterns that protect the caller** from bad dependencies: **timeouts** (stop waiting), **circuit breakers** (stop calling a failing dependency), **bulkheads** (limit how much of your capacity one dependency can consume) and **fallbacks** (serve something useful instead of an error). **Patterns that protect the callee** from too much demand: **rate limiting** (cap requests per client), **load shedding** (reject excess work early), **concurrency limits** and **back-pressure** (signal callers to slow down). **Patterns that handle transient faults**: **retries with backoff and jitter**, **idempotency** so retries are safe, and **hedging** for tail latency. They are applied in **client libraries** (Resilience4j, Polly), in **gateways** and **service meshes** (Envoy, Istio), and in **infrastructure** (load balancers, autoscalers). The rest of this course covers each family and how they combine.

## Patterns at a glance

Who each pattern protects and where it usually lives.

```text
pattern               protects   typical location            main parameter
--------------------  ---------  --------------------------  ---------------------------
timeout               caller     every client call           duration (from latency p99)
retry + backoff       caller     client / mesh               attempts, backoff, jitter
circuit breaker       both       client / mesh               failure rate, open duration
bulkhead              caller     client (pools, semaphores)  max concurrent calls
fallback              user       client                      what to return instead
rate limiter          callee     gateway / server            requests per window per key
load shedding         callee     server / LB                 queue time or concurrency
concurrency limit     callee     server                      adaptive in-flight limit
idempotency key       data       server                      key retention window
```

## Safety systems in a car

Brakes (timeouts), anti-lock braking (backoff), airbags (fallbacks), crumple zones (bulkheads) and speed limiters (rate limits) each handle a different danger. You want all of them, configured for your car, not just one big airbag.

**Quiz:** Which pattern primarily protects a service from receiving more requests than it can handle?

- [ ] Timeout
- [ ] Fallback
- [ ] Hedged requests
- [x] Rate limiting or load shedding

*Answer:* Rate limiting or load shedding. Rate limiting and load shedding protect the callee by rejecting excess demand.
