The problem
The old design did the work in the process that scheduled it. That is fine until the process stops existing, and in a system that deploys regularly it stops existing often. A campaign halfway through its recipients lost the rest, silently, and the only evidence was a customer asking why half their list never heard from them.
A queue fixes the obvious part: a job outlives the process that created it. It also introduces four problems that are less obvious, and those are what this case study is about.
Measured on production once it was live at 15 sends a second, throughput went from the loop's median of 56 messages a minute to 785-809. The largest real run sent 18,615 contacts in 23.6 minutes, where the loop would have needed about five and a half hours. Across 20,637 sends in that window: zero duplicates, zero double charges, no rate-limit rejections. The speed is the headline, but the second sentence is the one that took the work, and the four sections below are how it was earned.
1. Two workers must never claim the same recipient
Sending a WhatsApp message costs money and is visible to a real person, so a double send is worse than a slow send. The claim therefore cannot be a read followed by a write, because two workers can both read "unclaimed".
The claim and the state change are a single Lua script executed by Redis. Redis runs it atomically, so there is no window between checking and taking. This is the same argument as a unique index in a database: put the invariant where the concurrency actually is, rather than in application code that races.
2. A queue can accept a job it never delivers
Under load, an add can report success without the job arriving. If you trust the queue, those recipients are lost exactly as before, and you have added infrastructure without fixing anything.
So a reconciler runs continuously, comparing what the campaign intends to send against what the queue actually holds, and re-adding the difference. It runs one pass at a time, skips campaigns an earlier pass is still inside, and its hold on a campaign expires after fifteen minutes so a hung pass cannot stall everything else.
3. An unanswered send is not a failed send
When the provider never responds, the state of that message is unknown, not failed. Marking it failed means retrying it, and retrying something that actually went out means sending it twice.
Those rows settle into an in-doubt state instead. It is the single most important distinction in the system, and it is the one that someone reading the code six months later is most likely to erase by "simplifying" it.
4. Cleaning up a job is not enough
Dropping an orphaned job leaves its entries behind in Bull's rate limiter, which then throttles later campaigns against work that no longer exists. Clean-up has to remove the job and its limiter entries.
Nothing in the documentation says this. It comes from watching a queue behave strangely in production and following the discrepancy until it made sense.
What else came with it
- Pause and resume that cannot double-send. A leftover job checks the run's state before it sends, so resuming a paused campaign does not re-fire work that was already in flight.
- A circuit breaker. If the sending number cannot send, the campaign pauses, holds its unspent credit reservation rather than refunding and re-charging, and can be resumed.
- Per-campaign lanes, so one slow campaign does not block the reconciliation of every other one.
What I would want to know next
When I first wrote this up the queue was behind a flag for a handful of companies, and I would not quote a speed number because none had been measured. It went to every company on 24 October 2026, and the figures above come from production rows over the four days that followed: a median of 56 messages a minute on the old loop against 785 to 809 on the queue at 15 sends a second.
What I would still want to know: the ceiling is a configured send rate, not a discovered one. 15 a second is where we stopped raising it, not where it stopped working, so the real headroom is untested. The next change is per-number lanes, so one large campaign cannot sit in front of another account's login codes, and that improves fairness rather than throughput.
What I would tell someone building this
- Decide what your claim key is before anything else, and make the claim atomic at the storage layer.
- Assume your queue loses work; write the reconciler on day one, not after the incident.
- Keep "unknown" as a state. Collapsing it into "failed" is how systems double-charge and double-send.
- When something behaves oddly under load, follow it. The rate-limiter residue was invisible in every test and obvious in production.