profullstack / profullstack/rssamplifier.com
Redis write queue halves throughput and stalls the import drain; disabled in production
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 4
- Forks
- 0
- Avg merge
- 24m
- Merged PRs (30d)
- 61
Description
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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading client.js and the connection path around connect(), then inspect createWriteWorker and the Redis queue setup. Reproduce with REDIS_URL on the poller while watching import_entries and crawl logs. Done means selecting and implementing a queue design that avoids the global bottleneck, then measuring throughput and confirming imports drain before re-enabling production configuration.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, redis, sqlite
- Domain
- backend, databases, distributed-systems, performance
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100