Can two requests claim the same short URL?
One skill · 5 minutes · Speak or type · Whiteboard optional
The challenge
Design the code-allocation part of a URL shortener receiving 100 million new links per month. Reads greatly outnumber writes. In five minutes, state your assumptions and explain how two concurrent requests avoid assigning the same short code to different links. A full architecture is not required.
Try a 5-minute design challenge
Try the interview without an account. Create a free account to see your report.
Illustrative example — not your assessment
An invented, synthetic answer to a different challenge: Does your rate limit still hold across three servers?
For this fixed-window policy, all three servers use the same customer/window key and an atomic admission decision. If the limiter is unavailable, this design rejects requests to preserve the cap, at an availability cost.
This is an invented example written for this page, not a customer answer.
About this challenge
Read this after you have tried the challenge. It explains one approach.
Generating a short code and safely claiming it are different steps. A random generator can produce a code that already exists. If two servers both check that a code is free and then write, they can race. Put the uniqueness decision in an atomic operation and explain what happens to the losing request. A coordinated unique-ID allocator is another valid design; encoding its output changes the representation, not the uniqueness guarantee. Your answer should connect the operation to the invariant: one code must not resolve to two different destinations.
Explain what happens when two requests collide
More challenges
- Does your rate limit still hold across three servers?
- What happens to your feed when delivery falls behind?
MockSchool AI offers AI-driven interview practice. Feedback is practice feedback on the part of the answer you give, not a prediction of any interview outcome.