Retries & backpressure
Retry only what is safe to retry, and shed load locally before the server sheds it for you.
What to retry
| Status | Retry? | Strategy |
|---|---|---|
| 202 | no | Accepted. Re-submit only events listed in errors. |
| 400 / 401 / 403 / 422 | no | Deterministic failures; fix the request first. |
| 408 / 429 / 5xx | yes | Exponential backoff with jitter, honour Retry-After. |
Backoff
Start at 250 ms, double to a 30 s ceiling, and add ±20% jitter. Cap total attempts at 6; beyond that, spill the batch to a local queue and retry on a slower timer.
delay = min(30s, 250ms * 2**attempt)
delay *= random.uniform(0.8, 1.2)
sleep(max(delay, retry_after))
Backpressure
A sustained 429 rate above 1% means the client is emitting faster than the plan allows. Two options:
- Buffer locally. Keep a bounded ring buffer of pending batches and drop the oldest events, counting drops in a metric you actually alert on.
- Reduce cardinality. Aggregate high-frequency events client-side — for example, counters per minute instead of one event per request.
Do not retry with a new
Idempotency-Key. That converts a safe retry into a duplicate write, which Meridian cannot deduplicate.Connection reuse
Keep-alive matters more than batch size for cross-region clients: a fresh TLS handshake costs roughly 2–3 round trips. Reuse a single HTTP/2 connection per worker and cap concurrency at 8 per core.