> ## Documentation Index
> Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Notify 50 Million Users

> Explains why polling fails for 50 million users and recommends push topic notifications via FCM plus strategies to handle post-notification traffic surges.

Scenario: your app has 50 million users and marketing needs to notify everyone about a flash sale. The interviewer asks: would you use polling or push notifications (for example, Firebase Cloud Messaging (FCM))? If you pick FCM, do you need to send 50 million individual messages?

This guide walks through both approaches, shows the cost and operational implications, and explains the production-ready pattern for large-scale notifications.

## Polling: why it doesn’t scale

With polling, each client periodically asks your server, “Is the sale live yet?” If the sale hasn’t started, the server replies “Not yet.” The client waits a fixed interval (for example, 20 seconds) and asks again.

Do the math:

* 50,000,000 devices checking every 20 seconds ≈ 50,000,000 / 20 = 2,500,000 requests per second.
* Almost all responses will be negative (“No”) until the sale begins.

This pattern requires enormous server capacity just to answer “No” and forces frequent background network activity that drains battery on mobile devices.

![A stylized infographic showing a server labeled "Your Server" polling many phone icons (noted as 50,000,000 phones) with connecting lines. A caption at the bottom reads "...and almost every answer is NO" with a red "NO" button.](https://mintcdn.com/kodekloud-c4ac6d9a/2h0o-_DtLcLu6HM7/images/DevOps-Interview-Questions-and-Answers-Scenario-Based-Prep/System-Design/Notify-50-Million-Users/your-server-polling-50m-phones-no.jpg?fit=max\&auto=format\&n=2h0o-_DtLcLu6HM7\&q=85\&s=d0de04e7f3102073e9da1824b8cd6b36)

Comparison at a glance:

| Approach | Requests per second (approx) | Battery impact | Operational cost | Delivery latency |
| -: | :-: | :-: | :-: | :-: |
| Polling (20s) | `2,500,000` RPS | High (frequent wakeups) | Very high | Dependent on poll interval |
| Push (FCM topic) | 1 publish to topic | Low (OS-managed) | Low | Near-instant (platform-dependent) |

Conclusion: polling at this scale is inefficient, costly, and battery-unfriendly.

## Push notifications with FCM / APNs

Push notifications are the correct pattern for large-scale, time-sensitive notifications. On Android, devices maintain a single long-lived connection to Google’s servers (via Google Play services). Your backend sends messages to Firebase Cloud Messaging (FCM) and FCM pushes them over existing connections.

Do you send 50 million separate messages? No — use topic-based pub/sub. Each app instance subscribes to a topic such as `flash-sale`. Topics support very large subscriber sets. When the sale starts, your server publishes a single message to the `flash-sale` topic and FCM fans the message out to all subscribers.

![A diagram showing a pub/sub push-notification flow: "Your Server" publishes a "topic: flash-sale" message to Google/FCM which then fans out to many mobile phones. The graphic indicates delivery to 50,000,000 phones.](https://mintcdn.com/kodekloud-c4ac6d9a/2h0o-_DtLcLu6HM7/images/DevOps-Interview-Questions-and-Answers-Scenario-Based-Prep/System-Design/Notify-50-Million-Users/fcm-pubsub-push-flash-sale-50m.jpg?fit=max\&auto=format\&n=2h0o-_DtLcLu6HM7\&q=85\&s=58c6f07a1e7ddaa567395c9aa3f1af1b)

Two practical points to mention in an interview or design doc:

* Priority: mark the message as high priority so it can wake sleeping devices for immediate delivery. Normal-priority messages may be deferred to save battery.
* Time-to-live (TTL): push delivery is not guaranteed immediately to every device. If a device is offline, FCM may queue the message. For a flash sale, a long-delayed notification is harmful; set a short TTL so expired messages are discarded.

Set high priority for immediate wake-up and a short TTL so notifications that miss their window are not delivered late.

Example — publish to topic `flash-sale` with high priority and short TTL (FCM HTTP v1 JSON):

```json theme={null}
{
  "message": {
    "topic": "flash-sale",
    "notification": {
      "title": "Flash Sale — Starts Now!",
      "body": "Tap to shop limited-time offers."
    },
    "android": {
      "priority": "high",
      "ttl": "10s"
    }
  }
}
```

Always verify delivery semantics and supported fields against the official docs: [Firebase Cloud Messaging docs](https://firebase.google.com/docs/cloud-messaging) and [Apple Push Notification service (APNs)](https://developer.apple.com/notifications/).

## After the notification: the real danger — traffic surge

The main operational risk comes seconds after you deliver the notification: millions of users tapping the banner at once. That surge can overwhelm checkout services, inventory systems, payment gateways, caches, databases, and other downstream dependencies.

![A dark infographic showing "Your Server" at the top linked to a box labeled FCM and Google, which feeds a grid of phone icons. It visually represents sending push notifications to many devices (noted as 50,000,000 phones).](https://mintcdn.com/kodekloud-c4ac6d9a/2h0o-_DtLcLu6HM7/images/DevOps-Interview-Questions-and-Answers-Scenario-Based-Prep/System-Design/Notify-50-Million-Users/server-fcm-google-push-50m-phones.jpg?fit=max\&auto=format\&n=2h0o-_DtLcLu6HM7\&q=85\&s=e80714737ae82cb6ee926b8e48411cdf)

Key mitigation strategies:

* Autoscale and pre-warm
  * Configure aggressive autoscaling policies for your front-end and critical services.
  * Use warm pools or pre-warmed instances for latency-sensitive paths (e.g., checkout).
* Throttle, token-bucket, and queue
  * Place a rate-limiting layer in front of critical endpoints.
  * Use durable queues to smooth bursts and process traffic at a controlled rate.
* Staged rollouts / segmented topics
  * Publish to segmented topics (by region, user cohort, or randomized segments) and roll out in waves to reduce peak concurrency.
* Caching and CDNs
  * Serve static and cacheable content from CDNs to reduce origin load.
  * Apply aggressive caching for product pages where possible.
* Idempotency and optimistic concurrency
  * Ensure purchase and reservation operations are idempotent.
  * Use optimistic concurrency or reserve inventory to prevent oversell.
* Circuit breakers and graceful degradation
  * Fail fast for non-essential features and surface clear messages to users when capacity is constrained.
* Database scalability
  * Use read replicas, sharding, partitioning, and monitor for hotspots. Prepare to scale writes and reads independently.
* Third-party resilience
  * Anticipate limits on payment providers and other external APIs; implement retries, backoff, and alternative flows.

Even with perfect notification delivery, user behavior can create massive, sudden load. Design your backend to absorb bursts: queueing, throttling, staged rollouts, and capacity planning are essential.

## Summary

* Polling 50M users is inefficient and battery-unfriendly — it generates millions of mostly-negative requests per second.
* Use push notifications (FCM / APNs) with topic-based pub/sub to avoid per-device sends.
* Mark flash-sale messages as high priority and set a short TTL to keep notifications timely.
* The bigger challenge is the surge of user actions after the notification — prepare with autoscaling, queuing, throttling, staged rollouts, caching, and resilient third-party handling.

Further reading and references:

* Firebase Cloud Messaging docs: [https://firebase.google.com/docs/cloud-messaging](https://firebase.google.com/docs/cloud-messaging)
* Apple Push Notification service (APNs): [https://developer.apple.com/notifications/](https://developer.apple.com/notifications/)

> [card] [Watch Video](https://learn.kodekloud.com/user/courses/devops-interview-prep/module/ef53ec43-96e9-4d1b-8a6e-e6eb97b0d0dc/lesson/1a63e8c3-e120-45c3-b180-30c2b835195f)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.