Skip to content
System Designer

Easy · Telecom and messaging

One-time code by text

Apps ask you to send a six-digit code to a phone. The code must arrive in seconds, a person must never get it twice, and nobody may use your system to spam a number. Texts go through a carrier partner with a hard speed limit and a real price per message. Practise this easy system design problem for free with a Google or GitHub account.

The brief

Apps ask you to send a six-digit code to a phone. The code must arrive in seconds, a person must never get it twice, and nobody may use your system to spam a number. Texts go through a carrier partner with a hard speed limit and a real price per message.

Think of the login code text that arrives in seconds.

Users, scale and requirements

Who uses it
3 million people a month (approx.)
Audience in plain numbers
3,000,000 people per month
Normal peak
≈ 40 requests per second
Request mix
Notification: 20%; Write: 30%; Read: 50%
Speed for 99 of 100 requests
Write: ≈ 400 ms; Read: ≈ 400 ms
Successful requests
99.9%
Data safety
At most 1 minute of writes may be lost.
Monthly budget
≈ $94,000
Data at rest
≈ 0.2 TB
Where users are
North America: 50%; Europe: 30%; Asia Pacific: 20%
Home region
North America
Waiting deadlines
Notification: 10 seconds; Write: 3,600 seconds; Read: 900 seconds

≈ marks an approximation, just as in the game. Waiting deadlines measure the age of queued work and are separate from interactive response time.

  • The carrier partner accepts about 100 texts a second per sender in this scenario (approx.).
  • Each text costs about a cent (approx.). Every code is a real bill.
  • All numbers are rough approximations.
  • Notification speed measures provider acceptance. Device receipt is outside this traffic model; check expiry, provider outcome and retries in the correctness trace before claiming delivery guarantees.

Questions that shape the design

How fast must the code arrive?

Within about 10 seconds of the request. Late codes are as bad as none.

Can the same request be sent twice?

Apps retry when they are unsure. Send each code only once.

What stops abuse?

Limit how many codes one phone number can get in a few minutes.

The traffic day

Consumer traffic, busiest in the evening. The clock covers 00:00 to 24:00 in the home region. Events add pressure on top of that normal traffic.

  1. 09:00 · Provider rate limit

    An outside service lowers its configured request quota and answers 'too many requests' above the reduced limit.

    Provider capacity falls to 80% of its configured quota. Duration: ≈ 3,600 seconds.

  2. 13:00 · Duplicate delivery

    The queue redelivers messages. Without duplicate protection, side effects may be applied twice.

    Affected share: 5%. Duration: ≈ 3,600 seconds.

What a strong design has to handle

  • The carrier has a speed limit and a code that arrives late is useless. What smooths a burst without delaying everyone?
  • A queue can delay a code when the carrier slows. Giving codes their own queue keeps marketing texts from waiting in the same line.
  • Strict per-number limits stop abuse but may block a real person who retries a few times.

Make a prediction, run a full traffic day, then compare the result. The in-game editorial opens after a finished day and includes measured reference designs.

Concepts to practise

Related problems