Backpressure policy roadmap: shedding variants, watermarks, limiter placement #6
cognis-digital
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
safequeue supports three backpressure policies when a bounded-capacity queue is full (see
docs/ARCHITECTURE.md):PolicyReject(default) — fail fast withErrBackpressure(HTTP429). Producer slows down / retries.PolicyDropOldest— dead-letter the oldest ready message to admit the new one (leased messages are never dropped).PolicyBlock—EnqueueWait(ctx, ...)blocks until room or the context is canceled.I'd like input on where to take this next.
1. Load-shedding variants.
DropOldestfavors fresh work (good for live telemetry). Should we add:2. High/low watermarks instead of a hard cap.
A single
Capacityis a hard wall. A common pattern is hysteresis: start shedding/throttling at a high watermark and stop only once depth falls back below a low watermark, to avoid thrashing at the boundary.Depth()already exposes current + high-water. Is watermark-based admission worth adding?3. Where should the rate limiter sit relative to backpressure?
Right now
ratelimitis a separate package the caller composes in front ofEnqueue. Should the queue optionally own an admission limiter (config-wired, per-fairness-key), or is keeping them decoupled the better design? Decoupled is more flexible; integrated is more turnkey.4. Backpressure signaling to producers.
Beyond
429, would aRetry-Afterheader (derived from the limiter'sReserve().Delay()or from drain rate) be useful for HTTP clients?What backpressure behavior do your workloads actually need — fail-fast, block, or shed — and at what depth?
All reactions