High-Volume Sovereign Bulk SMS: Campaign Architecture, Throughput Scaling, and Carrier Rate-Limit Avoidance
A production architecture for high-volume bulk SMS: TPS provisioning maths, BullMQ and Celery worker queues, token-bucket pacing per carrier, and STOP opt-out processing that never leaks a send.
The campaign was ready: four hundred thousand opt-in recipients, a message approved by legal, and a launch window of ninety minutes. The first ten thousand messages left the queue in under a minute. The next ten thousand returned errors. By minute three, the sender ID had been throttled by two carriers, the queue had backed up to a hundred and eighty thousand jobs, and the retry logic was re-attempting every failure at once. The campaign eventually delivered, seven hours late, with roughly eleven percent of recipients receiving the message twice.
Nothing in that story is exotic. Every element is a predictable consequence of treating bulk SMS as a loop over an array instead of as a queueing system with external rate limits. The carrier imposes throughput limits you do not control; the queue must therefore be the thing that absorbs pressure, and the retry policy must be the thing that prevents pressure from compounding.
This guide builds that system. It covers the throughput arithmetic you need before provisioning, a BullMQ worker topology with a global ceiling and per-carrier pacing, the equivalent shape in Celery, the opt-out pipeline that must be checked both at enqueue time and at send time, and the campaign checklist that keeps a large send inside carrier tolerances. If your volume is a few hundred messages a day, you do not need most of this — a loop with a sleep is fine. The moment you cross into five-figure campaigns, you do.
What does high-volume bulk SMS require architecturally?
High-volume bulk SMS requires four things: a durable queue that survives worker restarts, a global throughput ceiling expressed in messages per second, per-carrier pacing so no single route is saturated, and an idempotent send key so a retry can never become a duplicate message. The throughput ceiling must be derived from the carrier’s accepted rate rather than from your ambition — sending faster than a route accepts does not deliver messages sooner, it produces 429 responses, a backed-up queue, and a sender ID that carriers begin to filter. Plan capacity in messages per second, enforce it in the worker, and let the queue absorb every spike.
The reason a naive loop fails is that it conflates two different limits. Your capacity is how many messages you can hand to the API per second. The route’s acceptance rate is how many it will accept before throttling. When capacity exceeds acceptance, the surplus does not queue politely at the carrier; it comes back as errors, and your retry logic converts those errors into another burst. The system oscillates, and the amplitude of the oscillation grows until either the campaign finishes or the sender ID is blocked.
Throughput arithmetic before you provision
Campaign planning should start with a table, not a spreadsheet of phone numbers. The numbers below convert a target rate into a delivery window, which is what you actually promise the business.
| Sustained rate | Per hour | Per day (24 h) | Time for 100,000 |
|---|---|---|---|
| 10 msg/s | 36,000 | 864,000 | 2 h 47 m |
| 50 msg/s | 180,000 | 4.32 M | 33 m 20 s |
| 200 msg/s | 720,000 | 17.3 M | 8 m 20 s |
| 500 msg/s | 1.8 M | 43.2 M | 3 m 20 s |
| 1,000 msg/s | 3.6 M | 86.4 M | 1 m 40 s |
Rates are sustained throughput, not burst. Real campaigns are bounded by the slowest destination corridor, not by the aggregate number.
Read the table with the slowest corridor in mind. If eighty percent of a campaign goes to a market where a single sender ID sustains twelve messages per second, the campaign takes the time implied by twelve per second regardless of how much aggregate capacity you have provisioned elsewhere. This is why per-destination pacing matters more than raw worker concurrency: the bottleneck is almost never the queue, it is one route inside it.
Queue architecture: enqueue idempotently
The first job of the queue is not throughput; it is durability. A campaign that lives in a for-loop dies with the process, and a campaign that lives in Redis or RabbitMQ survives a deploy, a crash, and a scaling event. The second job is idempotency: each recipient becomes exactly one job with a deterministic ID, so re-enqueuing a campaign after a partial failure cannot produce a second message to anyone.
import { Queue } from "bullmq";
import IORedis from "ioredis";
const connection = new IORedis(process.env.REDIS_URL, {
maxRetriesPerRequest: null, // required by BullMQ workers
});
const outbox = new Queue("sms-outbox", { connection });
export async function enqueueCampaign(campaign) {
// Suppression is filtered BEFORE the queue so opted-out numbers
// never occupy capacity. It is re-checked at send time as well.
const rows = await loadRecipients(campaign.id, { excludeSuppressed: true });
const jobs = rows.map((r) => ({
name: "send",
data: { campaignId: campaign.id, to: r.e164, body: campaign.body },
opts: {
// Deterministic id: a re-run of this campaign cannot duplicate a send.
jobId: `sms:${campaign.id}:${r.numberHash}`,
attempts: 4,
backoff: { type: "exponential", delay: 2_000 },
removeOnComplete: 5_000,
removeOnFail: false, // keep failures for reconciliation
},
}));
// addBulk is pipelined; chunk it so one huge campaign does not
// block the Redis connection for other tenants.
for (let i = 0; i < jobs.length; i += 1_000) {
await outbox.addBulk(jobs.slice(i, i + 1_000));
}
return { enqueued: jobs.length };
}
Two lines in that snippet deserve emphasis. The
jobId derived from the campaign and the recipient hash is
what makes the whole pipeline idempotent — without it, a redeploy mid-campaign that re-runs the enqueue
step sends everyone a second message. And removeOnFail: false keeps failed jobs visible, because a bulk
campaign is only finished when you can account for every recipient: delivered, failed permanently, or
suppressed.
The worker: one global ceiling, per-route pacing
The worker enforces the two limits that keep a
campaign inside carrier tolerances. BullMQ’s built-in limiter provides the global ceiling, and a per-destination
token bucket provides the fine-grained pacing that the global limiter cannot express. Error classification is
the third piece: a 429 must be retried, a 400 must not.
import { Worker } from "bullmq";
import IORedis from "ioredis";
const connection = new IORedis(process.env.REDIS_URL, {
maxRetriesPerRequest: null,
});
const API = "https://api.sendsmsnokyc.com";
const GLOBAL_TPS = Number(process.env.GLOBAL_TPS ?? 200);
// Per-destination ceiling, in messages per second. Fill from your
// own measured acceptance rates; conservative defaults below.
const ROUTE_TPS = { US: 15, IN: 8, NG: 5, BR: 20, PH: 6, default: 10 };
const buckets = new Map(); // route -> { tokens, lastRefill }
function take(route) {
const rate = ROUTE_TPS[route] ?? ROUTE_TPS.default;
const now = Date.now();
const b = buckets.get(route) ?? { tokens: rate, lastRefill: now };
b.tokens = Math.min(rate, b.tokens + ((now - b.lastRefill) / 1000) * rate);
b.lastRefill = now;
buckets.set(route, b);
if (b.tokens < 1) return false; // caller waits and retries the job
b.tokens -= 1;
return true;
}
new Worker(
"sms-outbox",
async (job) => {
const { campaignId, to, body } = job.data;
// Re-check suppression at send time: a STOP may have arrived
// between enqueue and dispatch.
if (await isSuppressed(to)) return { skipped: "suppressed" };
const route = await routeFor(to); // MCC/MNC to country mapping
if (!take(route)) {
// Move the job to the delayed set; do not count it as an attempt.
throw new Error("route_throttled");
}
const res = await fetch(`${API}/v1/sms/send`, {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.SMSROUTE_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
to,
message: body,
sender_id: process.env.SENDER_ID,
idempotency_key: `${campaignId}:${job.id}`,
}),
});
if (res.status === 429 || res.status >= 500) {
throw new Error(`retryable_${res.status}`); // BullMQ applies backoff
}
if (res.status >= 400) {
// Permanent: bad number, blocked content, unregistered sender.
// Return (not throw) so the job is not retried forever.
return { failed: res.status, body: await res.text() };
}
return res.json();
},
{
connection,
concurrency: 25,
limiter: { max: GLOBAL_TPS, duration: 1_000 },
},
);
The Celery equivalent follows the same shape
with different primitives: rate_limit on the task
replaces the BullMQ limiter, and self.retry with a
computed countdown replaces the automatic backoff. The classification logic must be identical, because the
failure mode is the same in either stack: retrying a permanent error turns a fast failure into an infinite one.
import os, httpx
from celery import Celery
app = Celery("sms", broker=os.environ["REDIS_URL"])
app.conf.task_acks_late = True # survive worker death mid-send
app.conf.worker_prefetch_multiplier = 1 # fair dispatch across workers
@app.task(
bind=True,
max_retries=4,
rate_limit="20/s", # per-worker ceiling
acks_late=True,
)
def send_sms(self, to: str, body: str, campaign_id: str, number_hash: str):
if is_suppressed(to): # re-checked at send time
return {"skipped": "suppressed"}
r = httpx.post(
"https://api.sendsmsnokyc.com/sms/send",
headers={"Authorization": f"Bearer {os.environ['SMSROUTE_API_KEY']}"},
json={
"to": to,
"message": body,
"sender_id": os.environ["SENDER_ID"],
"idempotency_key": f"{campaign_id}:{number_hash}",
},
timeout=10.0,
)
if r.status_code == 429 or r.status_code >= 500:
# Exponential backoff with jitter: 5s, 10s, 20s, 40s (+/- jitter)
raise self.retry(
countdown=5 * 2 ** self.request.retries + random.uniform(0, 3)
)
if r.status_code >= 400:
return {"failed": r.status_code, "body": r.text} # permanent
return r.json()
Three Celery-specific settings matter for bulk
sending and are routinely left at their defaults. task_acks_late = True means a message is acknowledged only
after the task completes, so a worker that dies mid-send re-queues the job rather than losing it — safe
precisely because the send is idempotent. worker_prefetch_multiplier = 1 stops one worker from
reserving a thousand tasks it cannot process, which is what produces wildly uneven progress across workers. And
jitter on the retry countdown prevents every failed job from retrying at the same instant, which is the
mechanism that turns a brief 429 into a sustained overload.
Avoiding carrier rate limits
Carriers do not publish a single throughput number, and they do not throttle by a single rule. What they enforce in practice is a set of heuristics about whether traffic looks like a well-behaved application or a bulk blast, and the difference between those two classifications is usually pacing plus sender-ID reputation. The table lists the levers that matter, in the order they tend to bite.
| Lever | What goes wrong without it | How to implement |
|---|---|---|
| Per-route pacing | One destination saturates and returns 429 for everyone | Token bucket keyed on destination country |
| Ramp-up on new sender IDs | A brand-new ID at full volume looks exactly like abuse | Start at 5–10 msg/s, double every 30 min to target |
| Send-time spread | Uniform bursts at :00 look automated | Jitter dispatch across a window |
| Opt-out compliance | Complaint rates trigger filtering fast | Suppression checked at enqueue and at send |
| Content hygiene | Shortened links and ALL-CAPS trigger spam heuristics | Branded domain, plain text, clear sender identity |
| Failure isolation | One bad route poisons the whole campaign | Circuit-break the route, continue others, alert |
Ramp-up schedules should be agreed with your provider before a large launch, because the route’s tolerance is a property of the interconnect, not of your account settings.
The ramp-up row is the one teams skip and then regret. A sender ID with no history, pushing ten thousand messages in its first minute, is indistinguishable from an attack on every signal a carrier can see. Doubling from a modest starting rate costs a few hours on a large campaign and dramatically reduces the probability of being filtered at the moment the campaign matters. If you cannot afford the ramp, you cannot afford the risk of a blocked route either — and the block outlasts the campaign.
Opt-out processing that never leaks a send
Opt-out handling is the control most likely to be tested by a regulator and most likely to be implemented incorrectly. The failure pattern is always the same: suppression is checked when the campaign is built, a recipient sends STOP while the campaign is still draining, and a message goes out afterwards because nobody re-checked at dispatch. On a campaign that takes ninety minutes, that window is large and the mistake is guaranteed.
| Inbound keyword | Action | Notes |
|---|---|---|
| STOP, STOPALL, UNSUBSCRIBE, CANCEL, END, QUIT, OPTOUT, REVOKE | Suppress globally, immediately | Treat as case-insensitive and whole-message |
| HELP, INFO | Reply with programme details | Required by US programme rules for many campaigns |
| START, YES, UNSTOP | Re-subscribe only with fresh consent | Record the new opt-in timestamp; do not silently re-enable |
| Any other reply | Route to support queue | Do not auto-respond with marketing content |
Keyword sets vary by destination and programme. Verify the required list for each market and keep the set configurable rather than hard-coded.
The implementation is small, but the ordering discipline is what matters: check suppression before enqueueing, and check it again immediately before the HTTP call. Both checks read the same table, so a STOP that lands at any point in the campaign’s lifetime takes effect for every message not yet dispatched.
const OPT_OUT = /^(stop|stopall|unsubscribe|cancel|end|quit|optout|opt-out|revoke)$/i;
const HELP = /^(help|info)$/i;
const RESUME = /^(start|yes|unstop)$/i;
// Inbound webhook handler: record the decision, then acknowledge once.
export async function handleInbound({ from, text, receivedAt }) {
const body = text.trim();
if (OPT_OUT.test(body)) {
await db.suppression.upsert({
number: from,
reason: "user_opt_out",
keyword: body.toUpperCase(),
at: receivedAt,
});
await db.audit.write({ number: from, event: "opt_out", at: receivedAt });
return { action: "suppressed" };
}
if (HELP.test(body)) {
return { action: "help", reply: "Msg rate varies. Reply STOP to cancel." };
}
if (RESUME.test(body)) {
// Re-enable only with a fresh, recorded consent event.
await db.suppression.delete({ number: from });
await db.consent.insert({ number: from, source: "sms_keyword", at: receivedAt });
return { action: "resubscribed" };
}
await db.support.enqueue({ from, body, receivedAt });
return { action: "routed_to_support" };
}
// Called by the worker immediately before dispatch. Cheap by design:
// one indexed lookup against a table that is small and hot in cache.
export async function isSuppressed(e164) {
return Boolean(await db.suppression.findByNumber(e164));
}
Two operational details complete the picture. First, suppression must be checked in both places even though it looks redundant: the enqueue-time check keeps opted-out numbers from consuming queue capacity, and the send-time check closes the race. Second, the suppression table should be keyed on the normalised E.164 number, because “STOP” from a number stored in a different format is the same person and must suppress the same record. Format mismatches here are the most common reason a suppressed number still receives a message.
The pre-campaign checklist
Everything below has been the cause of a real incident in a five-figure-or-larger campaign. Run it before every launch, not once per quarter, because campaigns differ in destination mix and that is what changes the risk profile.
| Check | Failure it prevents |
|---|---|
| Balance covers the full send plus retries | A campaign that stops mid-drain when funds run out |
| Global TPS set below the slowest route ceiling | Sustained 429s and a growing retry backlog |
| Per-route token buckets configured | One corridor starving every other destination |
| Ramp schedule agreed for new sender IDs | Filtering triggered in the first minutes |
| Suppression filtered at enqueue and at send | A message to someone who already replied STOP |
| Opt-out instruction present in the body | Complaints instead of opt-outs, and filtering |
| Quiet-hours window enforced in local time | Night-time delivery complaints and TCPA exposure |
| GSM-7 sanitisation on the body | Segment count doubling the invoice |
| Idempotent job IDs and send keys | Duplicate messages after a mid-campaign redeploy |
| Circuit breaker per route with alerting | A silently failing route discovered hours later |
| Reconciliation report for delivered, failed, suppressed | Unaccounted recipients at campaign close |
Frequently asked questions
How many messages per second can I actually send?
Aggregate capacity is usually high and rarely the constraint. The binding limit is the acceptance rate of the slowest destination corridor in the campaign, which depends on the sender type, the route, and the relationship between your provider and the terminating operator. Measure it with a pilot in the target market rather than assuming a figure, and set the global ceiling below the slowest route you intend to use.
Should I use BullMQ or Celery?
Either works; pick the one your team can operate. BullMQ gives you a first-class rate limiter and simple delayed retries with Redis. Celery gives you mature task routing, broad broker support, and a well-understood operational model for Python teams. The architecture is identical in both: durable queue, deterministic job identity, global ceiling, per-route pacing, classified retries, and suppression re-checked at dispatch.
Why do duplicate messages appear after a redeploy?
Because the send was not idempotent. If the enqueue step runs again on deploy and the job identity is random, every recipient gets a second message. Derive the job ID and the send’s idempotency key from stable inputs — campaign ID plus a hash of the normalised number — and the second enqueue is a no-op instead of a duplicate.
What should happen when one route starts failing?
Isolate it. Open a circuit breaker for that destination, keep draining every other route, and alert. The alternative — letting failures accumulate in the same queue as healthy work — is what turns a single bad interconnect into a campaign-wide incident, because retries from the failed route compete for worker slots with first attempts from routes that are working fine.
Do I need a registered sender ID for bulk sending?
For some destinations, yes. Alphanumeric sender IDs are widely accepted for transactional traffic, but markets such as India and several Gulf states require pre-registration, and US long-code campaigns require A2P 10DLC brand and campaign registration with the throughput tier attached to the campaign type. Confirm the requirement per destination before the campaign, because a registered-ID market will drop unregistered traffic without an error you can act on.
Jacky Hossein
Verified AuthorPrincipal Telecommunications & Cryptographic Systems Architect at SMSRoute. Specializes in carrier-grade SS7/SMPP routing protocols, non-custodial cryptocurrency billing rails, and zero-knowledge telecommunications privacy.
Send Global SMS in Under 60 Seconds Without KYC
Sign up with email only. Top up with Bitcoin, USDT, Monero, or Ethereum. Instant carrier interconnects to 149 countries from $0.004/msg.