~learn.
0:00 / 1:31
Interview problem · Notification system

50 million sale messages, then your login code. Who goes first?

transcript

10 AM. Marketing sends a sale to 50 million people. 10:01. You ask for a login code. Does it wait behind the sale?

Normal traffic: OTPs, order updates. About 116 a second. The campaign: 50 million in an hour. About 13,900 a second. Over 100 times more.

Share one queue, and your code waits behind millions of sale messages. It has to leave in seconds. So it never shares anything with bulk.

The OTP goes to a high topic. Its own consumers. Its own workers. The campaign goes to bulk. Released in batches, at a rate providers can take. And the SMS budget is split. 30 percent is reserved for high. Always. Bulk gets the rest. It can never use the OTP's share.

The cost? Assume the SMS account allows 1,000 a second. The campaign's SMS take 42 minutes. With 700 a second left for bulk, about an hour. A slower sale. A fast OTP.

But here's the catch. Which alarm tells you OTPs are in trouble? Not queue depth. The campaign makes it huge on purpose. Watch the age of the oldest message in high. That's the one users feel.

Separate topics. Separate workers. Separate provider budgets. The OTP never waits behind the sale.

Full breakdown in the lecture.