← All articles

Notification pipelines that send each push once, on time

Updated Nov 10, 2026 · 4 min read

A push notification looks like one API call. In practice it’s a pipeline, because the hard parts are everything around the call. Pushes have to go out fast when they matter, never twice, never at 3 a.m. for a sale, and not at all when the user turned them off. Getting that wrong is how apps lose permission to notify anyone.

APNs and FCM

You don’t talk to phones directly. Apple’s Push Notification service (APNs) delivers to iPhones, and Google’s Firebase Cloud Messaging (FCM) delivers to Android. Each phone registers with them and gives your app a device token. To send, your server makes an HTTPS request with the token and the message, signed with your app’s key. APNs and FCM accept many requests at once over one HTTP/2 connection, so a single worker can keep a lot of pushes in flight.

Why a queue

The action that triggers a push, like a like or a follow, shouldn’t wait for it. If the API calls APNs inline, a slow APNs makes every like slow, and a down APNs fails them. Instead the API puts a job on a queue, answers right away, and a pool of workers sends pushes at their own pace. When APNs has a bad minute the queue grows, then drains.

Eventlike, follow…Notifiersettings, limitsQueuesby priorityWorkersdedupe, retryAPNs / FCMPhone
Decide whether to send, give the push an id, queue it by priority, and let workers talk to APNs and FCM.

Decide before you queue

A notifier service sits in front of the queue and decides whether a push should exist at all. It checks the user’s settings, whether they’ve muted this kind of push, their quiet hours in their own time zone, and how many pushes they’ve had lately. Doing this first means a push nobody wants never costs a worker.

  • Settings. If the user turned off “new follower” pushes, drop it.
  • Quiet hours. Hold anything that isn’t urgent until their morning.
  • Per-user limits. After a few like alerts in an hour, roll the rest into one summary, such as “Sam and 28 others liked your photo”.

At least once, and dedupe ids

Queues deliver each job at least once. If a worker sends a push and crashes before telling the queue it’s done, the queue can’t know the push went out, so it hands the job to another worker. Asking for exactly once doesn’t help, because no queue can see inside your worker. The fix is to make the repeat harmless.

Give every notification an id when it’s created, before it’s queued, so every retry carries the same one. When a worker sends, it records the id in a shared store with an atomic “set if missing”, such as Redis SET id 1 NX EX 86400. If the id is already there, another worker got to it first, and this one skips it. APNs’s apns-collapse-id header and FCM’s collapse key add a second line of defense, because the phone replaces a push with the same id instead of showing both.

Retries with backoff

Some failures are worth retrying and some aren’t. Read the answer before you try again.

ResponseMeansDo this
200AcceptedMark it sent
410 from APNs, UNREGISTERED from FCMThe app was uninstalledDelete the token and stop sending to it
429You’re sending too fastSlow down and retry later
500, 503Their problem, for nowRetry with backoff
400Your request is wrongDon’t retry. Log it and fix the bug

Retry with exponential backoff, waiting 1 second, then 2, then 4, and add a little randomness, called jitter. Without jitter, a thousand workers that failed together retry together, and hit the struggling service at the same instant again. After a few tries, give up and record the failure, rather than retrying forever.

Priority

A queue is a line. If a campaign puts 30 million pushes in it, a password reset code joins behind them. Give urgent pushes their own queue with workers that never touch anything else. The urgent line stays nearly empty, so resets and security alerts go out in seconds no matter how big the campaign is. Some pipelines add a third, middle queue for ordinary social pushes.

How many workers

Size the bulk workers for the biggest campaign and its deadline. A campaign to 30 million phones that must go out within 10 minutes is 30,000,000 ÷ 600 seconds, or 50,000 pushes a second. If one worker sends 1,000 a second, you need 50 workers for those 10 minutes, and far fewer the rest of the day. That’s a good reason to scale bulk workers up for a campaign and down after it, while the urgent workers stay put.