KatInterview

Building a Reliable Future-Dated Money Transfer Scheduler

System DesignModel answer
MediumModel answerSystem Designsystem-designschedulerpayments

Last updated

Design a service that fires transfers at a chosen future time, moves money atomically between accounts, and skips any transfer whose source balance is too low at that moment.

Problem

Design a feature that lets users register a money transfer to take place at a specific moment in the future. When that moment arrives, the system must carry out the transfer, adjust the balances of both accounts involved, and not carry it out if the paying account lacks enough funds at that time.

What to cover

In your answer, walk through:

  1. Requirements and assumptions. Functional behavior, the meaning of "on time", ordering rules, and expected scale including bursts.
  2. API and data model. How transfers are created, cancelled and listed, and how money and state are stored.
  3. Architecture. How the system notices that a transfer is due and how it gets executed.
  4. The execution step. How you guarantee each transfer runs once, balances stay correct, and an insufficient balance results in a skip rather than a partial or overdrawn payment.
  5. Failure modes and trade-offs. Worker crashes, duplicate triggers, cancel-versus-execute races, load spikes, and accounts living on different shards.
  6. Validation and rollout. How you would test and release this safely.

If you want an extra challenge, describe how you would implement a simplified single-process version where every operation carries a timestamp and all transfers due at or before that timestamp must be processed before the operation itself.

Hints

Hint 1

Split the problem into two parts: something that decides when a transfer becomes due, and something that moves the money correctly. Most correctness lives in the second part.

Hint 2

Make the state change itself the guard: a conditional update that only succeeds if the transfer is still in its initial state means duplicates and races become harmless no-ops.

Hint 3

Combine the balance check and the debit into one conditional statement, and lock accounts in a consistent order to avoid deadlocks. For a simulated clock, a min-heap ordered by due time plus a sequence number gives deterministic processing.