KatInterview

Build a Multi-Channel Alerting Pipeline for a Social App

System DesignModel answer
MediumModel answerSystem Designsystem-designnotificationsmessage-queue

Last updated

Design a backend that turns events from many product services into push and in-app alerts, with preferences, batching, rate limits, priority lanes, and safe retries.

You are designing the alerting backend for a large social network. Many internal product services (comments, reactions, friend requests, direct messages, event reminders) emit events that may need to become user-facing alerts.

Alerts must reach users in two ways:

  • As push messages on their mobile devices, via third-party push providers.
  • As entries in an in-app alert list, including an unread count.

Whether email or SMS are also needed is part of what you should clarify.

What to cover

  1. Clarifying questions you would ask and the assumptions you pick (channels, event volume and burstiness, latency per alert type, user controls, and whether a duplicate or a missed alert is worse).
  2. A high-level architecture and the main data flow from producer to device.
  3. How producers submit events, and how you make submission safe to retry.
  4. How you check user preferences and eligibility before sending.
  5. How you group related events and limit how many alerts a single user receives.
  6. How urgent alerts are kept from getting stuck behind bulk traffic.
  7. How you deliver through third-party push providers, and how you handle failures, bad device tokens, and stale alerts.
  8. How you store the in-app list and keep unread counts correct.
  9. How you avoid duplicates when components retry.
  10. Which metrics you would monitor.

State your scale assumptions explicitly and discuss the main trade-offs.

Hints

Hint 1

Start by splitting the system into stages joined by durable queues: ingest, decide (preferences, dedup, grouping, rate limit), render, and per-channel delivery. Each stage can then scale and fail on its own.

Hint 2

Think about where duplicates come from: producer retries, consumer redelivery, and provider timeouts where you do not know if the send succeeded. A deterministic notification ID used as an idempotency key at each hop helps with all of them.

Hint 3

Use separate queues, consumer pools, or quotas for urgent traffic (messages, security) versus bulk traffic (reactions, digests), and decide which stage applies per-user caps and collapsing so a viral post does not flood one person.