The Runtime Theory
mediumleetcode#key-generation#read-heavy-service#caching

Design a Short-Link Service

Design short-link creation and redirection from traffic assumptions through identifier generation, storage, cache, and abuse controls.

The Runtime Theory Team1 min read
Solve it

Solving happens on the judge — come back and mark it done

Sample cases

inCreate two links for different long URLs

outEach short identifier maps to the intended destination

inRedirect with unknown, expired, or disabled identifier

outReturn a defined not-found or unavailable response without leaking internal details

Design a service with create(longUrl) and redirect(shortCode). Begin by asking about traffic volume, link lifetime, custom aliases, privacy, and availability goals. Estimate the relative read and write rates before choosing a storage layout.

Explain how identifiers are generated without collisions, how the mapping is stored, and what happens when a redirect misses cache. Define expiration and deletion behavior. Add rate limits and abuse handling; the ability to create a link can be misused for phishing or malware distribution.

Discuss whether the redirect is permanent or temporary and how that affects caching. The linked coding problem focuses on encoding and decoding; your design note should include operational, security, and failure behavior beyond the data structure.

More practice in this topic

One dispatch a week

The trace behind each problem, the tradeoff that explains it, and one technical dispatch per week — no noise.

One technical dispatch per week. No noise.

Not started

Sign in to save your learning progress.

Sign in to save