Functional
- Create a short alias for a validated HTTP(S) URL, with optional custom alias and expiry.
- Resolve an alias to its current destination and return an HTTP redirect.
- Disable abusive links and collect click events without delaying redirects.
Resolve compact links with low latency while creating globally unique aliases.
Design for a 10× peak and cache the read path.
The write path can favor correctness over extreme throughput.
Partition by alias and apply lifecycle policies.
Random allocation makes collision probability operationally negligible with checks.
These are reference assumptions, not universal facts. In an interview or architecture review, change them when the product context changes.
/v1/linksCreate an alias; accept Idempotency-Key and optional expiry./{alias}Return 301/302 redirect without waiting for analytics./v1/links/{alias}Disable an owned alias and invalidate caches.alias PK, destination, owner_id, created_at, expires_at, statusAlias is the partition key; destination is validated and normalized once.alias, occurred_at, coarse_region, referrer_classAppend asynchronously; never join this store on the redirect path.Resolve aliases and return redirects
Create collision-safe short codes
Durably store alias-to-URL records
Serve hot redirects close to users
Generate 128 bits of randomness, encode the first 8–10 Base62 characters, and use conditional insert. Retry only on collision. Custom aliases use the same uniqueness boundary but stricter reservation and abuse checks.
Cache positive mappings for hours and disabled/unknown aliases briefly. Publish invalidations on delete or destination change. During invalidation lag, a short TTL bounds exposure; high-risk disable operations can consult a denylist at the edge.
Allocate aliases in the accepting region with a globally unique conditional write or region-prefixed ID. Replicate mappings outward, then acknowledge only after the local read path can resolve the alias.
Fall back to the mapping store, cap concurrency, and shed nonessential analytics.
Use an idempotency key so one request cannot create multiple aliases.
Move here when: Launch and validate the product.
Move here when: Origin traffic or global latency becomes material.
Move here when: Regional continuity and local creation are required.
Strong answer signal: Discuss browser/CDN caching, destination mutability, and analytics visibility.
Strong answer signal: Move resolution to edge caches; partition click events independently.
Strong answer signal: Use an idempotency key and a retrievable operation result.