← Docs
Recipe

Recipe: Back-pressure handling

Prevent overload cascades when downstream systems slow down. Apply circuit breakers, token buckets, and exponential backoff with jitter to keep Meridian stable under load.

1. Token bucket rate limiter

Refill tokens at a fixed rate. Reject requests when the bucket is empty. Use Redis or in-memory counters with atomic operations.

2. Circuit breaker

Track failure counts over a sliding window. Open the circuit after a threshold, fail fast, and probe with a half-open state before restoring traffic.

3. Exponential backoff with jitter

Retry with capped exponential delay and random jitter to avoid thundering herd. Never retry indefinitely — set a max attempts ceiling.

4. Offline grace cache

When the license server is unreachable, serve from a local HMAC-signed cache with a configurable TTL. Invalidate on next successful check-in.

Tip: Combine all four patterns. Rate-limit at the edge, break circuits on downstream failures, back off retries, and cache offline. Your system degrades gracefully instead of collapsing.