The interview problem

Practice prompt

Launch a public username feature where thousands of clients may request the same short name. Guarantee one current owner and support renaming without check-then-write races.

Original practice, not a reported company interview. All scenarios and worked numbers are illustrative. Interview date: not applicable. Sources retrieved September 30, 2026.

1. Scope and assumptions

Assume a single authoritative transactional store per normalized name. Availability during a partition is secondary to uniqueness. Names are user-facing identifiers, distinct from globally allocated numeric IDs.

2. Worked approach

normalized name + request ID
  → unique atomic claim
  → durable outcome
  → profile cache

Define and version normalization before storing a unique normalized-name key. Decide case, whitespace and allowed-character policy explicitly; do not silently change it during a release. Claim through one atomic insert protected by the unique constraint, with an idempotency key mapping to the request result. Availability checks are hints, not reservations.

Rename in a transaction that claims the new name and releases or redirects the old one according to policy. Bind the operation to the current account and name version. Keep old-name reuse delay explicit to reduce impersonation risks; cache invalidation must not make a released name appear owned by two accounts. Route authoritative profile lookup by the current claim record.

3. Calculate the example

If 5,000 requests check availability before any insert completes, all may observe available. A unique constraint still permits only one successful claim; 4,999 requests receive a conflict or recover their own prior idempotent result. With 2 million claims at an illustrative 160 bytes of logical row data, raw payload is 320 MB before indexes, transaction metadata and replicas. The hot-name serialization point, not that storage size, dominates launch contention.

4. Failure cases and trade-offs

An application-only mutex on one server cannot coordinate other servers. Normalization mismatches create visually or semantically conflicting names. A lost success response must return the existing outcome on retry rather than report that the user's own new name is unavailable.

Per-name partitioning scales independent claims but cross-partition rename needs an explicit transaction or reservation protocol. A single store is simpler for an initial launch. Relaxed availability checks are acceptable; relaxed committed uniqueness is not.

5. Validate the result

Run concurrent identical claims, case variants, retries after commit and rename/reuse races. Confirm one authoritative owner, stable idempotent responses and explicit behavior for unsupported characters.

6. Interview follow-ups and self-review

How would a normalization-policy migration detect collisions? Can a username be transferred?

Reward an atomic invariant, normalized-key policy, retry recovery and safe rename semantics.

Sources and related practice

Technical reference: www.postgresql.org — Database uniqueness enforcement; username lifecycle design is original.

Exact publication/update date not established in this review. Retrieved September 30, 2026. This reference supports the named technical concept; the proposed workflow and examples are original, not a documented vendor implementation or interview report.

Continue with Design a cross-shard transaction coordinator; Allocate sortable identifiers across regions.

Continue your preparation

Choose a connected learning path or browse more System design questions. Read our editorial method and attribution policy.