Queueing review: overload control, retry behaviour, global rate limits and utilization signals
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- postgresql, rust
- Ambito
- backend, databases, performance
Direzione di ricerca
This issue spans several proposed changes and modeling work rather than naming a single implementation entry point. Start by reading ADR-035, ADR-010, the configuration docs, and docs/concepts/scaling-a-hot-queue.md; then choose one proposed item and its stated analytic check, simulation, or benchmark. Done for the full issue means the prioritized changes are justified by measurements or a model, with the listed overload, outage, and multi-runtime scenarios covered.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
A review of awa against standard queueing results and current overload-control practice. The structure holds up well; the gaps are in what happens when offered load exceeds capacity, and in the signals operators need to see it coming. This issue collects the findings, proposes changes in priority order, and sets out how to model or measure each before committing to it. The completion-batching latency bug found in the same review is #732.
What already matches good practice
- One pooled queue per workload. Workers claim from shared lanes, so a queue with c workers behaves like one M/M/c queue rather than c separate M/M/1 queues; Erlang C gives the pooled form much lower waiting time at the same load. Enqueue shards keep the pooling because workers claim across all shards.
- Pull with no prefetch beyond capacity. A dispatcher claims only as many jobs as it has free worker permits, so no job waits in one worker's buffer while another worker is idle (the join-idle-queue result).
- Little's law sizing. The configuration docs size permits as L = λW, and the bound on attempts waiting to be written stops a completion backlog from growing in memory.
- Delay-dependent priority. Priority aging bounds how long low-priority work waits while aging is on.
- Rate-limited recovery. Rescue drains abandoned attempts in budgeted passes instead of all at once.
Proposed changes
1. Overload control (extends #341)
When arrivals outpace completions (λ > μ) the backlog grows without bound; ADR-035 measured a COPY producer at about 10k/s against about 4k/s completion. Producer backpressure is #341. Two complementary pieces belong alongside it:
- Job expiry. An optional per-kind or per-job
expires_after, after which an unclaimed job is moved to a terminal state instead of being run. Work that is no longer useful should not take capacity from work that still is. - Act on waiting time, not queue length. CoDel and Facebook's adaptive LIFO both trigger on how long work has waited. awa already exposes the right signal (
lag_seconds, the age of the oldest available job); backpressure and alerting should key off it rather than depth. Newest-first service under sustained overload is an option for latency-sensitive queues, but not a default.
2. Retry jitter and retry budgets
Backoff is 2^attempt seconds plus 0–25% jitter, capped at 24 h (awa.backoff_duration). When a dependency fails many jobs at once, their retries return together within that 25% window and land on the dependency as it recovers. Retries that add load while the system is slowest are the mechanism behind metastable failures (Bronson et al., HotOS '21; Huang et al., OSDI '22).
- Use full or decorrelated jitter. The formula lives in SQL, so this ships as a migration replacing the function.
- Add a retry budget per queue or kind, for example retries capped at a share of first attempts over a window, or a circuit breaker per kind. It must not count rescues after worker crashes against the budget meant for handler failures.
3. Global rate limits
ADR-010's token bucket is per runtime, so N runtimes allow N times the configured rate, and a limit set to protect a downstream API loosens whenever the fleet scales out. Cheap approximation: divide the configured rate by the live runtime count from awa.runtime_instances. Precise version: a token bucket held in Postgres for queues that opt in.
4. Utilization signal and service-time guidance
Kingman's approximation, W_q ≈ ρ/(1−ρ) · (c_a² + c_s²)/2 · E[S], says waiting time climbs steeply as utilization ρ approaches 1 and scales with service-time variability c_s².
- Publish per-queue utilization (busy permits ÷
max_workers) and suggest alerting at about 0.8 sustained. - Document that kinds with very different service times belong on separate queues: one slow kind sharing a queue with fast ones raises the fast jobs' waits far more than its share of load suggests. The configuration docs currently give this advice only for deadlines.
5. Pooling caveat for PartitionedQueue
With hard-reserved capacity per partition, k partitions behave like k queues of c/k workers each. With skewed keys a hot partition saturates while others sit idle. global_max_workers or weighted overflow mitigates it; docs/concepts/scaling-a-hot-queue.md should say so.
6. Fair sharing within a queue
One tenant or key can take a whole queue. Per-key concurrency caps are #340; deficit or weighted round-robin across keys is the standard technique if fair shares are wanted rather than caps.
Modelling and measurement
Each change should be justified by a model or a measurement before it lands. In order of cost:
- Analytic checks. Use Erlang C and Kingman to predict waiting time for the benchmark queue shapes at measured service-time distributions, and compare with observed
lag_seconds. This validates the utilization alert threshold and the separate-queue guidance. - Discrete-event simulation. Simulate a queue fed by a dependency that fails for a window and then recovers: current jitter against full jitter, with and without a retry budget. Measure peak retry arrival rate at recovery, time to drain, and whether the system returns to its pre-failure state or stays degraded (metastability). Also simulate overload, λ above μ for a window, with and without expiry and backpressure, measuring goodput, defined as jobs completed while still useful.
- Benchmarks. The external benchmarking harness already drives offered load against awa. Add:
- an overload scenario (offered rate above capacity for a fixed window) recording depth,
lag_seconds, goodput and recovery time; - a dependency-outage scenario recording the retry wave;
- a multi-runtime scenario confirming the effective rate under per-runtime limits, before and after item 3.
- an overload scenario (offered rate above capacity for a fixed window) recording depth,
Suggested order
#732 first (a bounded bug), then retry jitter and the utilization metric (small and measurable), then the global rate-limit approximation, then job expiry together with #341.
- Lingua principale
- Rust
- Stelle
- 37
- Fork
- 8
- Merge medio
- 14h 16m
- PR unite (30g)
- 244
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di hardbyte/awa
-
feature
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 18/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
I maintainer di solito rispondono entro 1 giorno
-
0.6.19 release checklistApertaoperational
Difficoltà 5/5 Più di una settimana Idoneità per principianti 8/100
hardbyte/awa#861 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
hardbyte/awa#841 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di hardbyte/awa
Issue simili
-
Mobile release verification reports missing build inputs with a custom Cargo target directoryApertabug good first issue help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
getsotto/sotto-authenticator#139 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
registrystack/registry-stack#2924 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
foundry-rs/starknet-foundry#4733 ·
I maintainer di solito rispondono entro 4 giorni
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 86/100