Scheduler processes one batch per worker per tick: default throughput capped at <10 msg/s, backlog grows unbounded
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
Start in the OutboxScheduler in okapi-core, where scheduleWithFixedDelay runs processNext(batchSize) once per worker per tick, and read processBatch to see how each tick's transaction is opened. Change it so the loop keeps draining while a batch comes back full, with one transaction per iteration and a time or iteration budget that still lets stop() return promptly. Done means a sustained high publish rate no longer backs up the queue under default settings, stop() stays responsive, and the existing tests pass; the issue also asks for a benchmark of sustained throughput.
由索引模型根据 Issue 内容生成。
描述
Severity: High (performance / unbounded backlog) · Area: okapi-core OutboxScheduler · Found in: code review of main @ e5630a1
Problem
Each scheduler tick has every worker call processNext(batchSize) exactly once, using scheduleWithFixedDelay. That puts a hard ceiling on throughput:
max throughput ≈ concurrency × batchSize / (interval + batch processing time)
With the defaults (concurrency = 1, batchSize = 10, interval = 1s) that is under 10 messages/second, regardless of how fast the DB and transport are. Any sustained publish rate above that grows the backlog without bound, and latency grows linearly with it. A burst of 100k messages takes about 3 hours to drain with the defaults, even when each batch takes milliseconds.
Raising interval to cut idle polling makes this worse. Raising batchSize makes transactions longer (see the related issues on gap locks and delivery inside the transaction).
Suggested fix
In processBatch, keep draining while the previous batch was full. Each iteration gets its own transaction, and the loop is bounded by a time or iteration budget so stop() stays responsive:
do {
val n = transactionRunner.runInTransaction { outboxProcessor.processNext(config.batchSize) }
} while (n == config.batchSize && running.get() && !budgetExceeded())
That way the poll interval only governs idle latency, not peak throughput. The benchmarks should cover a sustained-rate scenario as well as fixed-backlog drains.
- 主要语言
- Kotlin
- 星标
- 14
- 派生
- 0
- 平均合并
- 14 小时 16 分钟
- 30 天内合并 PR
- 9
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
softwaremill/okapi 的其他 Issue
-
bug
难度 5/5 一周以上 新手友好度 35/100
softwaremill/okapi#141 ·
维护者通常 1 天内回复
-
OutboxProcessorListener events are emitted before the transaction commits; metrics over-count on commit failure可能已有人在做 @rawo 于 2 天前认领。 未关闭breaking-change bug
难度 4/5 3-5 天 新手友好度 35/100
softwaremill/okapi#137 ·
维护者通常 1 天内回复
-
enhancement
难度 4/5 1-2 天 新手友好度 42/100
softwaremill/okapi#136 ·
维护者通常 1 天内回复
-
bug
难度 3/5 半天 新手友好度 62/100
softwaremill/okapi#134 ·
维护者通常 1 天内回复
-
enhancement
难度 5/5 一周以上 新手友好度 22/100
softwaremill/okapi#133 ·
维护者通常 1 天内回复
查看 softwaremill/okapi 的全部 Issue
相似的 Issue
-
submit-adaption submit-adaption-pre
难度 1/5 1 小时以内 新手友好度 72/100
BetterAndroid/android-notification-icon-project#848 · 1 条评论 ·
维护者通常 1 天内回复
-
bug
难度 1/5 1-3 小时 新手友好度 70/100
orgzly-revived/orgzly-android-revived#1132 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
commons-app/apps-android-commons#7275 ·
维护者通常 1 天内回复
-
documentation
难度 2/5 1-3 小时 新手友好度 78/100
liberation-data/drivine4j#682 ·
维护者通常 1 天内回复
-
documentation good first issue
难度 2/5 1-3 小时 新手友好度 78/100
developmentwithyash/yaan#14 ·
维护者通常 2 天内回复