Persistence layer cannot differentiate or prioritize database request types
Background
Cadence enforces a global per-host/per-shard persistenceMaxQPS limit on requests to the database, shared across all callers: normal workflow API traffic (start/signal/query), replication tasks, background scanners, and admin/operational tooling. The only existing mechanism to differentiate callers is common/quotas.CallerBypass, which lets a configured caller type fully bypass the rate limiter when it's already saturated — an all-or-nothing escape hatch, not real prioritization.
Problem
When one traffic category (e.g. cross-cluster replication tasks) generates a sustained burst of persistence load, it can consume the entire persistenceMaxQPS budget. Because the limiter has no concept of relative priority between request categories, other traffic competing for the same budget — new workflow writes, admin operations — gets starved or throttled indiscriminately, even though it may be more latency-sensitive or operationally urgent.
Goal Cadence should be able to:
- categorize persistence requests by traffic type/caller (e.g. normal workflow traffic, replication, scanner/background work, admin)
- apply relative prioritization between those categories when the shared QPS budget is under pressure, so lower-priority traffic degrades before higher-priority traffic does
Proposed approach
Not yet decided; needs investigation into whether to extend the existing CallerType/rate-limiter primitives (common/quotas, common/persistence/wrappers/ratelimited) with weighted/priority-aware limiting, or introduce a separate mechanism (e.g. per-category token budgets, weighted fair queuing).
Acceptance criteria
- A design is agreed for classifying persistence requests into priority categories.
- Under sustained load from one category, other categories continue to make forward progress according to their relative priority, rather than being starved outright.
References
- Existing bypass mechanism:
common/quotas/caller_bypass.go - Existing caller-type primitive:
common/types/caller.go - Existing rate-limited persistence wrapper:
common/persistence/wrappers/ratelimited/
Source: cadence-workflow/cadence