GOAT EngineerPreparing your learning space…

System Design · Practice problem · Medium

Deliver Notifications Through a Rate-Limited Provider

Accept each notification quickly, store it in a durable queue, and let workers deliver it at the pace your provider allows. Mark a message done only after its work is saved, and make repeated work harmless.

Medium means two needs that pull against each other. You solve it on a canvas that runs your design. The canvas needs JavaScript; everything on this page works without it.

What is the situation?

Your app sends push notifications through a third-party provider. The provider answers in about 100 ms and accepts up to 500 calls a second from you. Send more than that and it refuses. Marketing sends campaigns without warning. Design the path from POST /notifications to the provider, so callers are answered quickly, nothing is lost, and each notification is recorded once in your deliveries table.

What must your design do?

  • Callers are answered within 100 ms at the 99th percentile.
  • At least 99.9% of notifications are accepted.
  • The oldest notification not yet delivered is at most 10 seconds old normally, 20 in a big campaign, and 30 after a crash or a provider outage.
  • No notification is left unrecorded, and none is recorded twice.
  • No worker drops a message, and no repeat doubles a write.
  • The system costs $600 a month or less.

What does Run test?

Run works without an account. It checks your design against 2 tests you can read before you start:

  • A normal hour. 300 notifications a second for 40 seconds.
  • A small campaign. At second 10, traffic rose by half for 5 seconds.

What does Submit add?

Submit needs an account. It runs 3 more tests you cannot read in advance, and stops at the first one your design fails, showing what happened and why. Passing every test, or giving up, unlocks the written solution.

Which parts can you use?

Already on your canvas: Provider, Deliveries.

  • Load Balancer: about 50,003 a second, $18 a month each
  • App Server: about 2,000 a second, $45 a month each
  • Queue: effectively unlimited, $25 a month each
  • Worker: about 200 a second, $45 a month each
  • Database: about 5,000 a second, $120 a month each
  • Outbox Relay: about 5,000 a second, $40 a month each

Every connection takes 1 ms, and the budget is $600 a month.

What does this problem leave out?

  • Whether the provider itself sends a duplicate: it has no memory of IDs, so your deliveries table is what we count.
  • Ordering per user.
  • User preferences and templates.
  • A provider that accepts a call and then fails later.

Where does this problem fit?

Its category is Notifications & webhooks: Deliver every message once, at a pace the receiver accepts. It practises queues & async, idempotency, rate limiting & protection and reliability & ops.

For the whole system, read the interview breakdown Design a Notification System.

See every practice problem.

By GOAT Engineer. Explore System Design · Privacy Policy · Contact.