Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Redis write queue halves throughput and stalls the import drain; disabled in production

未关闭
#138 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 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.

  • createWriteWorker runs at concurrency: 1, deliberately and correctly — SQLite permits one writer.
  • Every job is one client.batch(statements, 'write'), i.e. one remote Turso transaction, which client.js documents 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:

  1. 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.
  2. No folding to compensate. serializeWrites can fold several waiting callers into one transaction, but TURSO_WRITE_GROUP_STATEMENTS=1 in 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 serializeWrites does 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,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。