InterviewLegend

Design a Phone Number Change Across Services

Frequently asked
Alex Chen24 min readGuide updated
In this lesson
  • Model the user_phone_mappings table so a released number can be bound to someone else without losing history
  • Carry one change from the profile service to three downstream services reliably, with an outbox and an event topic
  • Work through a notifications outage and out-of-order events, then code the consumer that makes both safe

Understanding the problem

The prompt

Something like this: a user changes their phone number on the profile service. Three downstream services, Auth/2FA, Order Notifications and Marketing, each store indexed phone records of their own. Design the workflow that disassociates the old number everywhere.

This came up in a Bank of America Software Engineer loop in Q3 2026 that ended in an offer, in a round about architecture, schema design and resiliency. The follow-ups went in four directions. Draw the PostgreSQL table that maps users to numbers, and say how a unique index behaves when rows are soft-deleted. Explain how the change travels asynchronously from a Node.js edge to Spring Boot services. Decide what happens when the notifications service starts returning 503. And keep the consumers correct when the same event arrives twice or out of order.

It sounds small. One field changes. The trouble is that the field lives in four places, and in two of them it matters a lot. If the sign-in service still believes the old number belongs to this customer, a one-time passcode can go to a phone the customer gave up last week. Carriers recycle numbers, so that phone may now belong to a stranger. If the notifications service misses the change, order alerts keep going to the wrong person. So this is a data consistency question dressed up as a feature. The scale is modest. The hour goes on what happens when one of the four places is down, slow or behind.

The Bank of America angle
Bank of America design questions tend to arrive as concrete scenarios inside a technical panel rather than as a separate design round. This one comes with services already in place, so ask first: who owns the number today, how do the others hear about changes, and do they share a database? Then design the smallest fix.

Requirements

Functional requirements

Agree on the surface first. A customer submits a new number and proves they hold it, usually with a code sent to it. The profile service records the new number and releases the old one. Every downstream service stops using the old number and starts using the new one. Later, the old number can be bound to a different customer, because carriers hand numbers out again. Support staff can see which numbers a customer held and when.

In scope

  • Change a customer's number, with the old one released in one place of record
  • Propagate the change to Auth/2FA, Order Notifications and Marketing
  • Let a released number be bound to another customer later
  • Keep going when one downstream service is down or slow
  • Keep history of who held which number, and when

Out of scope (say so, then move on)

  • How the verification code is sent, beyond "an SMS provider"
  • Fraud scoring on the change itself, unless the interviewer raises it
  • The UI flow for the profile screen
  • Multi-region replication of the profile database

Non-functional requirements

Correctness first. A number must never be actively bound to two customers at once in the profile service, and the downstream copies must converge on the same answer. Security comes a close second. Auth/2FA should stop trusting the old number within seconds of the change. The other two services can lag. A marketing message going to the old number for ten minutes is a small nuisance. That difference is worth saying out loud, because it lets you give each consumer its own retry policy. Ask for numbers. If there are none, propose some. Say 60 million customers with a number on file, and about 50,000 changes a day, which is under one a second on average with peaks a few times higher. Nothing here is a throughput problem. One Postgres primary handles it with room to spare.

  • Changes: about 50,000 a day. A proposed figure. It averages under one a second, so the effort goes into failure handling.
  • Copies of each number: four. The profile service plus three downstream services, each with its own index on the number.
  • Auth/2FA lag: seconds. Sign-in codes must stop going to the old number almost at once.
  • Marketing lag: minutes is fine. A late update is a stray message, so this consumer can retry slowly.

The data model, in words

The profile service owns the truth, and the table the interviewer asks for is user_phone_mappings. Each row says one customer held one number from one moment until another. When a customer changes number, the current row gets a release time and a new row starts. Nothing is deleted. That's the soft delete, and it's what gives support the history. Every number is stored in one normalised form, the international E.164 format (a plus sign, country code and digits, like +17045550101). Without that, "(704) 555-0101" and "7045550101" are two different strings, and a unique index happily lets both be active for two different people.

Each customer also carries a phone version, a counter that goes up by one on every change. It travels with every event and is how a downstream service tells a new change from an old one that arrived late. The second table is an outbox: rows the profile service writes in the same transaction as the change, each one an event waiting to be published. Each downstream service keeps its own copy of the number plus a small table of event ids it has already handled.

Where each record lives
TableFields
user_phone_mappings (profile)mapping_id · user_id · phone_e164 · verified_at · bound_at · released_at
users (profile)user_id · phone_version · ...
outbox (profile)event_id · user_id · phone_version · old_phone · new_phone · created_at · published_at
phone copy (each downstream)user_id · phone_e164 · phone_version
processed_events (each downstream)event_id · processed_at
The profile service writes the mapping change, the version bump and the outbox row in one transaction. Downstream services never read the profile database. They learn about changes only from events.

The API

Two calls from the customer, one event between services. The change is split into start and confirm, because the new number has to be proven before anything is released. Release the old number first and the customer can end up with no number at all.

The interface
RequestServer push
AppProfile servicestart a change, sends a code to the new number
POST /users/{user_id}/phone-changes { new_phone }
change_id, expires_at
AppProfile serviceconfirm with the code; releases the old number
POST /phone-changes/{change_id}/confirm { code }
phone, phone_version
Safe to retry: a second confirm of the same change returns the same result.
Profile serviceDownstream servicesthe number changed
PhoneChanged { event_id, user_id, phone_version, old_phone, new_phone }
nothing; consumers acknowledge to the topic
Keyed by user_id, so one customer's changes stay in order on one partition.

The architecture end to end

The idea is that the profile service makes the change once, in its own database, and says so in an event. It never calls the other three services directly. Each downstream service listens, updates its own copy at its own pace, and can fall behind without holding anyone else up. In the diagram, blue is outside the system, violet is a service, amber moves messages and green is stored state. Tap any box for what it does.

Loading diagram...

1) Prove the new number. The Customer app starts the change through the Node.js edge. The Profile service checks the number isn't actively held by another customer and sends a code through the SMS provider. Nothing is released yet.

2) Commit the change once. On confirm, one transaction in the Profile database stamps a release time on the old mapping, inserts the new one, bumps the phone version and writes an outbox row. If the unique index rejects the insert because someone else bound that number a moment ago, the whole transaction rolls back and the customer sees a clear error.

3) Publish. The Outbox relay picks up the row and publishes it to the phone-changed topic, keyed by customer. Usually this takes well under a second.

4) Every copy catches up. The Auth and 2FA service, Order notifications service and Marketing service each consume the event and update their Downstream copies. Each one checks whether it has seen the event id and whether the version is newer than the one it holds. A consumer that keeps failing parks the event in the Dead letter queue and moves on.

Technology choices

  • The Profile database is PostgreSQL, as the interviewer named. We need a transaction across three tables and a unique index that applies only to active rows. Postgres supports that directly with a partial index, and plenty of other relational databases can get there with a filtered index or a generated column.
  • The phone-changed topic fits Kafka. Each service reads at its own pace as its own consumer group, events are kept for days so a service that was down can catch up, and keying by user id keeps one customer's changes in order. RabbitMQ with one queue per service would also work. The thing to defend is "durable, one copy per consumer, ordered per customer".
  • The consumers are Spring Boot services, and Resilience4j, which the interviewer brought up, gives them a circuit breaker and retry with backoff around outgoing calls. Spring Kafka adds retry topics and a dead letter topic, so the plumbing for the deep dive below already exists.
  • The Outbox relay can be a scheduled job polling the outbox every second, or Debezium reading the Postgres write-ahead log. Polling is easier to explain and plenty fast at one change a second.

Potential deep dives

How do you keep numbers unique when rows are soft-deleted?

The schema was the first follow-up in the 2026 loop, and it has a trap in it. You want two things that pull against each other. Released rows stay forever, for history. And a number can only belong to one customer at a time, which sounds like a unique index on the number. Put a plain unique index on the number column and the first release makes that number unusable forever, because the released row still holds it.

BadUnique index on the number, plus a deleted flag

Approach

Add an is_deleted column, set it on release, and keep a unique index on the number alone.

Challenges

The released row still occupies the number in the index. When the carrier recycles that number to a new customer, their insert fails with a unique violation. People then "fix" it by putting the flag in the index, unique on number plus flag, which allows only one deleted row per number. The second time a number is recycled, it fails again.

GoodHard delete the active row, copy it to a history table

Approach

Keep user_phone_mappings for active bindings only, with a plain unique index. On release, copy the row into a phone_history table and delete it, in the same transaction.

Challenges

It works, and the unique index stays simple. But history now lives in a second table with its own schema that has to be kept in step, and every query that wants "all numbers this customer ever had" needs a union. It's a fine answer, and a weaker one than the next.

GreatA partial unique index over active rows only

Approach

Keep every row in one table and mark a release by filling in released_at. Make the index unique only over rows where released_at is empty. Any number of released rows can share a number, while at most one active row can.

Challenges

Two details make it work. Normalise every number to E.164 before it touches the table, or the index compares strings that only look different. And let the index, not a read-then-insert check in code, be the final word, because two confirms racing for the same recycled number can both pass a read check.

It fits in one statement. Watch the WHERE clause, because that's what lets released rows pile up for history.

sql
CREATE UNIQUE INDEX one_active_owner_per_number
ON user_phone_mappings (phone_e164)
WHERE released_at IS NULL;

Add a second partial index the same way on the customer id, so each customer has at most one active number. Then the confirm transaction is: release the current row, insert the new one, bump the version, write the outbox row. If the insert hits the number index, roll back and tell the customer the number is already in use on another account. Keep released rows for as long as the retention policy says, since a bank will want to answer "who had this number in March" long after the fact.

The Bank of America angle
This is where the 2026 loop asked for the PostgreSQL schema. Draw the table, then the partial index, then say what happens when a recycled number is bound again. Naming E.164 normalisation and the race between two confirms shows you've run this in production.

How does the change reach the other three services?

The profile service has to tell three others, and some of them will be down at any given moment. The question is what the profile service does when the change is committed and the telling fails.

BadCall each service synchronously in the request

Approach

On confirm, the profile service updates its database and then makes three HTTP calls: to Auth, to Notifications, to Marketing. It returns to the customer when all three succeed.

Challenges

The customer's request now depends on four services being up. If Marketing is slow, the confirm times out. If the third call fails after the first two worked, you've changed the number in some places and not others, and there's no record of what's left to do. Every new service that cares about phone numbers means editing the profile service.

GoodCommit, then publish an event

Approach

The profile service commits the change and then publishes a PhoneChanged event to a topic. Each downstream service consumes it on its own.

Challenges

Much better: the request no longer waits on anyone downstream, and adding a fourth consumer needs no change to the profile service. But it's a dual write. If the process dies after the commit and before the publish, the event is lost and three services hold the old number forever. Publishing first has the opposite bug: an event for a change that then rolled back.

GreatTransactional outbox, then the topic

Approach

Write the event as an outbox row inside the same transaction as the change. A relay publishes outbox rows to the topic and marks them sent. The change and the intent to announce it commit together.

Challenges

The relay can publish a row twice, if it dies after sending and before marking. That's acceptable because the consumers already deduplicate. The cost is one more table and one more process, and a little latency, well under a second with a polling relay. In exchange, no committed change can go unannounced.

Saying the words "dual write" and then fixing it is most of the value in this dive. The Kafka and microservice consistency lesson goes further into this ground, including what to do when an event goes missing. One subtlety about the edge. The customer's call goes through the Node.js edge, but the event should not start there. If the edge published the change itself, it would be announcing something the profile service hadn't committed yet. The event belongs to whoever owns the truth.

What happens when notifications returns 503?

The interviewer will break something, and in the 2026 loop it was the notifications service returning 503 Service Unavailable. Be clear about where that happens. The consumer may be fine while something it calls is down, such as its own database or the SMS gateway, or the consumer itself may be rejecting work. Either way, events for it pile up. The goal is that this hurts nobody else and loses nothing.

BadRetry forever, in place

Approach

The consumer catches the error and tries the same event again in a loop until it works.

Challenges

Every retry hammers a service that's already struggling, which makes recovery slower. And because Kafka delivers a partition in order, the consumer is stuck on one event while every customer behind it on that partition waits too. One bad message can stall thousands of changes.

GoodBounded retries with backoff, then a dead letter queue

Approach

Retry a few times with exponential backoff and jitter, for example 1, 2, 4 and 8 seconds with some randomness so retries don't line up. If it still fails, publish the event to a dead letter queue with the error, commit the offset and move on.

Challenges

Nothing is lost and the partition keeps moving. But during a long outage every single event goes through the full retry sequence before landing in the queue, so the consumer burns time and keeps poking the sick service. And a later event for the same customer can now be applied before the parked one, which the next dive handles with versions.

GreatA circuit breaker in front, retry topics behind

Approach

Wrap the call in a Resilience4j circuit breaker. After, say, half the calls in the last 20 fail, it opens and fails fast for 30 seconds, then lets a few test calls through. While it's open, the consumer pauses its partitions instead of churning through retries. Events that fail for reasons unrelated to the outage go to a retry topic with a delay, then to the dead letter queue.

Challenges

This separates two kinds of failure. A whole service being down is handled by pausing and waiting, so no event is wasted on a hopeless retry. A single bad event, like a malformed number, is handled by parking it. Alert on the breaker opening, on consumer lag, and on anything arriving in the dead letter queue, and give the on-call engineer a replay tool.

The other two consumers never notice any of this. Each service is its own consumer group with its own position in the topic, so Auth keeps applying changes in seconds while Notifications is paused. That's the payoff of choosing a topic over synchronous calls, and it's worth pointing at when you get here.

The Bank of America angle
Resilience4j and Spring Boot came up by name in this loop, and lateral technical rounds at Bank of America lean hard on Java and Spring Boot depth. Use the real terms: the breaker's closed, open and half-open states, a sliding window, a wait duration. Precise vocabulary reads as experience.

How do you stay correct when events arrive twice or out of order?

In the 2026 loop this was the last follow-up, and it's where the design gets interesting. Duplicates are guaranteed: the relay can publish twice and the topic delivers at least once. Reordering happens too. A parked event gets replayed after newer ones, or a customer changes number twice in a minute and a retry slips the first change behind the second. There's also a harder kind of reordering that crosses customers. Alice releases a number and Bob is given it next month. Those are two customers, two keys, possibly two partitions. Bob's event can reach a downstream service before Alice's release does, and that service's own unique index on the number will reject Bob.

BadApply every event as it comes

Approach

Set the stored number to whatever the event says.

Challenges

A replayed old event quietly undoes a newer change, so the customer's number flips back to one they gave up. A duplicate is harmless only by luck. And Bob's early bind fails, so he gets no order alerts at all.

GoodDeduplicate by event id

Approach

Record each handled event id in processed_events, in the same transaction as the update. Skip any event already recorded.

Challenges

Duplicates are solved. Ordering isn't: an old event with a new id is still applied on top of a newer change. Recording the id outside the update's transaction reopens the gap, because a crash between the two either loses the update or applies it twice.

GreatEvent ids for duplicates, versions for order, retry for cross-customer conflicts

Approach

Check the event id first. Then compare the event's phone version with the one stored for that customer, and drop the event as stale if it isn't newer. If the new number is still actively held by another customer in this service's copy, don't apply and don't mark the event handled. Retry it later, because the release that frees the number is on its way.

Challenges

The version comes from the profile service's single transaction, so it's a true order for each customer without trusting clocks. Partitioning by customer keeps most events in order already, and the version catches the rest. The cross-customer case settles itself once the release lands, and if it doesn't within a few retries, the dead letter queue gets it and someone looks.

The rule each consumer applies, in order. The last line is the one most candidates miss: a conflict is not the same as a duplicate, so it must not be recorded as handled.

seen this event id? -> skip (duplicate)
version <= stored version? -> record id, skip (stale)
number active for someone else -> retry later, record nothing
otherwise -> release old, bind new,
store version, record id

You can code this rule yourself further down. It's small, and the four outcomes are all a consumer has to get right.

How do you know every copy agrees?

Events are the fast path, and even a careful system drifts. Someone fixes a row by hand, a dead letter sat unnoticed over a weekend, or a new service joined with a stale import. So add a slow path: a nightly job that compares each downstream copy against the profile service's active mappings, version by version, and republishes the latest event for any customer who doesn't match. Run it on the Auth copy more often, hourly perhaps, since that's the one with security consequences. Watch the obvious signals as well. Consumer lag per service, in seconds rather than messages. The circuit breaker's state. The size and age of the dead letter queue. And the count of conflict retries, since a rising number there means releases aren't arriving.

Practice the core in code

The consumer rule is the part of this design you can most easily get wrong in an interview, so here it is as one class. It stands in for one downstream service's copy of the numbers. It takes change events one at a time, in whatever order they arrive, and has to end up agreeing with the profile service.

1

Phone change consumer: duplicates, stale events and recycled numbers

Medium
Problem
A downstream service keeps its own copy of each customer's phone number. It receives change events that can arrive twice, late or out of order. A number can belong to at most one customer at a time, and a released number can later be given to someone else.

Write a class PhoneDirectory. apply(event_id, user_id, version, phone) processes one event and returns a status string. If event_id was already handled, return "duplicate". When version is not greater than the latest version applied for that user (0 if none), mark the event handled and return "stale". For a phone currently held by a different user, return "conflict" and change nothing, without marking the event handled, so a redelivery can succeed later.

In every other case, release the user's current number, bind phone to the user, store version, mark the event handled and return "applied". An empty phone means the user removed their number. owner(phone) returns the user holding phone, or null. current(user_id) returns the user's number, or null.

Input encoding. A test case is a JSON array of operations. The first entry is ["PhoneDirectory", []] and each later entry is [method, [args]]. The expected array holds each operation's return, with null for the constructor.
  1. PhoneDirectory()
  2. apply("e1", "alice", 1, "+17045550101")→ "applied"
  3. apply("e2", "alice", 2, "+17045550202")→ "applied"
  4. owner("+17045550101")
  5. current("alice")→ "+17045550202"

Alice changes number. The old number is released, so nobody owns it, and her current number is the new one.

How this uses the pattern

Keep four maps: handled event ids, latest version per user, number per user, and user per number. Check the outcomes in order: duplicate, stale, conflict, applied.

Write it here, or go full screen with the problem, hints and solution beside the editor.

Phone change consumer: duplicates, stale events and recycled numbers

Loading...
Click "Run" to execute your code
The Bank of America angle
This is the idempotent consumer from the design. The two mistakes that matter both show up in the tests. Applying an older version over a newer one flips a customer back to a number they gave up. Marking a conflicting event as handled means the redelivery is skipped as a duplicate, and the new owner never gets their number.
Take it further
Ask how it changes with persistence: the maps become tables, and the update plus the handled event id must commit in one transaction. Then ask what happens if a conflict never clears, which is when the event goes to the dead letter queue after a few retries.

What interviewers push on next

Should Auth wait for the event at all? Some candidates argue that sign-in is too sensitive for eventual consistency and should read the number from the profile service on every code it sends. That's a fair trade to discuss. You get perfect freshness and a hard dependency on the profile service for every sign-in. A middle path is to keep the event-driven copy and have the profile service mark the old number as untrusted in the same transaction, so a direct check can be done only for high-risk actions.

Tell the old number. A bank will usually want to send a "your number was changed" message to the old number, in case the change wasn't the customer's doing. That message must go out before Notifications forgets the old number. It's a nice example of an ordering rule inside one consumer, and easy to state once you've noticed it.

A fourth service joins. With a topic in the middle, a new consumer group reads from the oldest retained event, or from a snapshot of active mappings followed by the topic. The profile service doesn't change. Saying this out loud is the cleanest way to show why you picked events over direct calls.

Where the loop went next. In the same 2026 loop, the next round moved from design to operations. It covered diagnosing a production service that hangs, with thread dumps and database connection pool starvation (HikariCP, the usual pool under Spring Boot). Then it asked for a pitch for a strangler fig migration, where a new service takes over an old system's traffic one route at a time. If you're interviewing for a senior role, prepare for both.

What a strong answer looks like at each level

Software Engineer II. A clean skeleton you can explain: one owning service, an event to the others, a table with history. You reach the partial unique index with a nudge and can say why a plain unique index breaks on recycled numbers. The bar: the old number is released in one transaction and every consumer eventually agrees.

Software Engineer III and Feature Lead. You spot the dual write yourself and fix it with an outbox. You handle the 503 with bounded retries, a dead letter queue and a breaker, and you separate duplicates from stale events with ids and versions. The bar: you can say exactly what happens to one event when Notifications is down for an hour.

Senior Engineer and above. Lead the discussion. Raise the cross-customer conflict on recycled numbers before being asked, set different lag targets for Auth and Marketing, and add reconciliation and alerts. Be ready to argue when Auth should read the truth directly. The bar: the interviewer redirects you rather than rescuing you, and you're ready for the operations round that follows.

Common questions

Is this a typical Bank of America system design interview question?

It's the most detailed Bank of America design prompt reported in the last year, but it comes from a single Software Engineer loop in Q3 2026, so treat it as one example rather than a standard question. Most Bank of America design questions are practical scenarios asked inside a technical panel, and many are smaller than this. The system design overview lists the others with their dates.

Do I need to know Kafka for it?

You need the idea: a durable topic each service reads at its own pace, ordered per key, delivered at least once. Kafka is the common way to say it. Knowing PostgreSQL partial indexes and Resilience4j basics will help more, since those came up by name.

Key Takeaways

  • ✓Keep every mapping row and put a partial unique index over active rows, so a recycled number can be bound again.
  • ✓Write the change and an outbox row in one transaction, then publish, so no committed change goes unannounced.
  • ✓Guard each consumer with a circuit breaker and a dead letter queue, so one outage never stalls the others.
  • ✓Drop duplicates by event id, stale events by version, and retry cross-customer conflicts instead of marking them handled.
Bank of America interview guide

Know what Bank of America asks before you walk in.

32 coding · 5 system design · 43 behavioral questions

Get Premium$49 a year · Instant access
Or start freeNo card.

Get their questions first.

The Bank of America System Design RoundHad your Bank of America interview?How we research

InterviewLegend is independent and not affiliated with or endorsed by any company it covers.