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.