URL Shortener: Interview Guide
Staff-Level Discussion Topics
The following topics contain open-ended architectural questions without prescriptive solutions. They are designed for staff+ conversations where you demonstrate systems thinking, trade-off analysis, and strategic decision-making.
301 vs 302 Redirect Strategy
Level: Staff
Context: Your URL shortener serves both external marketing campaigns and internal employee tools. Product and engineering teams need to understand redirect behavior implications for different use cases.
Discussion Points:
- When would you choose 301 (permanent redirect) vs 302 (temporary redirect) and why?
- For an internal application, why is 301 better? How does it reduce server load?
- What are the browser caching implications of 301 vs 302 for both user experience and analytics?
- How does redirect choice affect click tracking and analytics accuracy?
- What happens if you need to change the destination URL after using 301? How would you handle migration?
- What organizational processes ensure the right redirect type is chosen for each use case?
Multi-Region Deployment and Global Consistency
Level: Staff
Context: A user in California creates a shortened URL. Seconds later, a user in Asia tries to access it. The URL returns 404. Your support team is flooded with complaints about "broken links."
Discussion Points:
- What is the replication latency across regions when a URL is created in one region and accessed from another?
- How long is the acceptable lead time before the URL is usable across the globe?
- How do you design for acceptable user experience during replication lag without compromising write latency?
- What trade-offs exist between strong consistency guarantees, eventual consistency, and write performance?
- When would you choose synchronous cross-region replication vs eventual consistency?
- How would you communicate these trade-offs to product and business stakeholders?
Service Health Monitoring and Failure Detection
Level: Staff
Context: It's 3 AM. Your on-call phone rings. The URL shortener is "broken" but monitoring shows all green. How do you know what's actually wrong and where to look?
Discussion Points:
- What are all the ways this service can break down? (database failure, cache failure, ID generator failure, network partitions, DNS issues, region outages)
- How do you detect each type of failure before users report it? What metrics and alerts would you implement?
- What monitoring and alerting strategy distinguishes between partial failures vs complete outages?
- How do you measure the "health" of the service from the user's perspective vs internal systems?
- What's your incident response playbook for each major failure mode?
- How do you handle cascading failures across components (e.g., database slow → cache overload → API timeout)?
Malicious URL Detection and Prevention
Level: Staff
Context: Security vendors have blocklisted your domain because phishing campaigns are using your URL shortener. Legitimate users can no longer share links. Revenue is dropping. The exec team wants answers.
Discussion Points:
- How would you detect and prevent malicious URLs from being created in the first place?
- What are the trade-offs between real-time URL scanning (adds latency to shortening) vs batch scanning (allows malicious URLs temporarily)?
- How do you handle false positives that block legitimate URLs? What's the user impact and support burden?
- What happens to existing malicious URLs that get reported after creation? How quickly can you take them down?
- How do you prevent your domain from being blocklisted by security vendors and email providers?
- What's the balance between security measures and user privacy (e.g., scanning destination content)?
Level Expectations
| Dimension | Mid-Level (L4) | Senior (L5) | Staff (L6) |
|---|---|---|---|
| ID Generation | Explain uniqueness and shortness requirements; suggest one valid approach | Compare hash vs UUID vs Snowflake vs Machine ID approaches with collision math | Design ID coordination across regions; handle clock skew, machine failures, and sequence recovery |
| Encoding Strategy | Explain Base62 encoding and calculate ID space (62⁶ ≈ 56B) | Discuss Base16/58/62/64 trade-offs; explain why special characters matter in URLs | Consider encoding implications for analytics, debugging, enumeration prevention, and URL patterns |
| Scaling Strategy | Understand sharding concept and why it enables horizontal scaling | Design shard key strategy using machine ID prefix; explain write path independence and read routing | Handle shard rebalancing, hot shards, consistent hashing alternatives, and capacity planning |
| Caching & Performance | Include cache layer in design; explain read-through pattern | Calculate cache hit ratios using Zipf distribution; design cache invalidation strategy | Design multi-tier caching; handle cache stampede, thundering herd, and stale-while-revalidate |
| Redirect Semantics | Know the difference between 301 and 302 | Trace impact on analytics, deactivation, and SEO; propose hybrid approach with Cache-Control | Design redirect policy per use case; handle migration from 301→302 without breaking cached redirects |
| Security | Mention rate limiting and input validation | Design pre-creation scanning, post-creation batch scanning, and enumeration prevention | Build comprehensive abuse prevention system; handle domain blocklisting, takedown processes, and organizational response |
Summary

Key Design Decisions
ID Generation: Machine ID + Sequence Number produces the shortest codes (6 characters) with guaranteed uniqueness and no runtime coordination. Alternative approaches (hash, UUID, Snowflake) either produce longer codes or require collision detection.
Encoding: Base62 (a-z, A-Z, 0-9) avoids URL-encoding issues from special characters while providing 56.8B capacity in just 6 characters — 30× our 5-year storage requirement.
Caching: Read-through + write-through hybrid achieves 90%+ cache hit rate. With Zipfian access distribution, 1 GB of Redis cache (~2M URLs) handles 93% of traffic, reducing database load to ~80 QPS.
Redirect Strategy: 302 (temporary) over 301 (permanent) preserves analytics accuracy and URL deactivation capability. A short Cache-Control: max-age (for example 5 minutes) is the middle ground: it absorbs repeat clicks, at the cost of counting at most one click per user per window.
Sharding: Not needed at today's volume (one primary with read replicas is enough). When one primary is outgrown, the machine ID prefix becomes the shard key: zero-coordination writes, each server writes to its own shard, and read routing extracts the prefix from the short code. No rebalancing is needed when adding shards.
Analytics: Two-tier counting (Redis HINCRBY for every click, a 60-second flush to the database) counts in sub-millisecond time without touching redirect latency; each flush collapses repeat clicks into one row update per link and applies each batch exactly once.
Architecture Principles Applied
| Principle | Application |
|---|---|
| Read-write separation | Cache absorbs 90%+ of reads; DB handles only writes and cache misses |
| Async over sync for non-critical paths | Analytics recording is fire-and-forget, never blocks redirects |
| Data locality via shard key | Machine ID prefix encodes the shard in the URL itself — no routing table needed |
| Defense in depth | Pre-creation scanning + post-creation scanning + rate limiting + deactivation |
| Evolve incrementally | Start with one server → shard when the data or writes outgrow one primary → multi-region for global latency |
Common Pitfalls to Avoid
| Pitfall | Why It Fails | Better Approach |
|---|---|---|
| Hash-based IDs with truncation | Birthday paradox: 50% collision probability after ~4,800 URLs (6 hex chars) | Machine ID + Sequence (guaranteed unique) |
| Base64 encoding | +, /, = break URLs and require encoding | Base62 (URL-safe, no special characters) |
| Direct DB increment for analytics | 1,160 write txn/sec to analytics table | Redis HINCRBY + periodic batch flush |
| 301 redirect for all URLs | Breaks analytics and deactivation (browser caches forever) | 302 with Cache-Control for hybrid approach |
| Eager scaling (sharding day one) | Operational complexity before it's needed | Single server handles 12 writes/sec easily |