Redis write queue halves throughput and stalls the import drain; disabled in production
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 30/100
- Issue 类型
- 重构
- 描述清晰度
- 需要澄清
- 活跃度
- 冷清
- 技术栈
- javascript, redis, sqlite
调研方向
首先阅读 client.js 和 connect() 周围的连接路径,然后检查 createWriteWorker 和 Redis 队列设置。在观察 import_entries 和 crawl 日志的同时,在 poller 上使用 REDIS_URL 重现问题。完成的标准是选择并实现一种避免全局瓶颈的队列设计,然后测量吞吐量,并确认 imports 在重新启用 production 配置之前已经处理完毕。
由索引模型根据 Issue 内容生成。
描述
REDIS_URL was set on both Railway services on 2026-08-19 to switch on the write queue from #132, which had been merged but never actually wired (the variable had never existed, so connect() had always taken the serializeWrites fallback).
It made throughput worse and stalled imports outright. REDIS_URL has been removed from both services, so production is back on the in-process path. The code is still merged and correct as written — this issue exists so nobody re-enables it without knowing what happens.
Measured, same database, same hour
| with Redis | after removing it | |
|---|---|---|
| items ingested / 10 min | 4,132 | 8,132 |
| feeds crawled / 10 min | 582 | 1,003 |
| import drain | stalled — 65,474 entries, unmoved for >1h | draining again |
| poller crawl tick | ms=823314, ms=500966 |
back to normal |
The poller logged crawl log write failed: The operation was aborted due to timeout continuously while it was on.
Why — it is not Redis being slow
Redis latency is irrelevant here. The cause is that the queue serialises writes that used to run in parallel, and the resulting ceiling is below what the workload needs.
createWriteWorkerruns atconcurrency: 1, deliberately and correctly — SQLite permits one writer.- Every job is one
client.batch(statements, 'write'), i.e. one remote Turso transaction, whichclient.jsdocuments at ~370ms. - So global write throughput is capped at roughly 1 / 370ms ≈ 2.7 transactions per second, cluster-wide, for every process combined.
Before the queue, that work was not serialised that way: serializeWrites is per-process (web and poller each had their own), and the crawl path runs under TURSO_CRAWL_AUTOCOMMIT=1, which issues single-statement execute() writes. Neither wrapper overrides execute, so those went straight to the database in parallel. Turning on Redis funnelled every batch() write in the cluster through a single 2.7/s consumer.
Two consequences worth calling out:
- Head-of-line blocking. BullMQ is FIFO with one consumer, so the import drain's large periodic batch queues behind every small crawl batch. That is why it did not merely slow down, it stopped.
- No folding to compensate.
serializeWritescan fold several waiting callers into one transaction, butTURSO_WRITE_GROUP_STATEMENTS=1in production disables that (default is 1; the comment notes a 5-crawl group exceeded the 30s request deadline when canaried). So neither path folds — the Redis path just adds a global serialisation point the in-process path never had across processes.
Also seen
MaxListenersExceededWarning: 11 closing listeners added to [Queue] on the poller — connect() builds a fresh Queue + QueueEvents pair on every call, so connections accumulate. Worth memoising the client regardless of what happens to this issue.
What would need to change before re-enabling
- Batch multiple jobs per transaction in the worker (fold at the consumer, since folding at the producer is what
serializeWritesdoes and it is switched off). - Or separate queues per class of write so a bulk drain cannot block interactive writes.
- Or raise the ceiling some other way — the 2.7/s figure is the thing to beat, and it should be measured before flipping the variable, not after.
Repro is cheap: set REDIS_URL on the poller, watch import_entries stop moving.
- 主要语言
- JavaScript
- 星标
- 4
- 派生
- 0
- 平均合并
- 20 分钟
- 30 天内合并 PR
- 54
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
dusk-network/exu#17 ·
-
难度 1/5 1 小时以内 新手友好度 88/100
jspreadsheet/ce#1809 ·
-
documentation
难度 1/5 1 小时以内 新手友好度 91/100
githubnext/gh-aw-workshop#4458 ·
维护者通常 1 天内回复
-
Add: Cartoonito未关闭check:failed feeds:add
难度 2/5 1-3 小时 新手友好度 63/100
iptv-org/database#37390 · 1 条评论 ·
维护者通常 9 天内回复
-
bug: directory index route root priority is overwritten when wildcard is false可能已有人在做 @TalhaHunter101 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 84/100
fastify/fastify-static#617 ·