Design a scalable URL shortener with expiration and security
Company: Coinbase
Role: Software Engineer
Category: System Design
Difficulty: hard
Interview Round: Onsite
Design a URL shortening service for hundreds of millions of users.
Requirements:
- Generate short URLs and redirect to original URLs.
- Enforce per-link expiration; expired links must not resolve.
- Provide high concurrency and thread/process safety with low-latency redirects.
- Sustain at least 100,000 requests per second.
Answer the following:
1) What data model, storage schema, and indexing would you use, and how would you implement TTL handling efficiently?
2) How would you generate collision-resistant, non-enumerable tokens? Discuss randomness, length, and access controls.
3) How would you clean up expired data efficiently? Compare lazy deletion versus scheduled batch sweeps and their impact on cache and storage.
4) How would you scale reads/writes with distributed caching and consistent hashing? Include cache invalidation and hot-key mitigation.
5) How would you design cross–data center replication and consistency guarantees for create/read operations, including handling propagation delay, failover, and conflict resolution?
6) What APIs, rate limiting, abuse prevention, and observability (metrics, logs, alerts) would you implement?
7) Provide capacity estimates (QPS, storage, bandwidth) with back-of-the-envelope calculations and SLOs for latency and availability.
Quick Answer: This question evaluates competency in large-scale system design and distributed systems, covering data modeling and TTL handling, storage and indexing, caching and consistent hashing, token generation and security, cross-region replication, operational concerns like rate limiting and observability, and capacity/SLO estimation.