Requirements, APIs, and Capacity Estimates
Core functional requirements: create a short URL, redirect a code to its destination, optionally set expiration, and allow authenticated owners to inspect or disable links. Non-functional goals may include low redirect latency, high read availability, abuse resistance, and durable mappings.
Define POST /v1/links, GET /{code}, and owner-management endpoints. Use an opaque code and store destination, owner, creation time, expiry, and status. Estimate create and redirect rates separately; redirects are usually much more frequent than link creation.
Choose a code-generation strategy that avoids collisions at the expected scale. Random codes need collision detection and retry; a counter-based generator needs coordination and may expose creation order. The code length should be based on the alphabet size and collision expectations, not guessed casually.
- Redirect reads and link creation have different workloads.
- Define expiration, ownership, and abuse requirements early.
- Code generation needs a collision and enumeration strategy.
Why should click analytics usually be decoupled from the URL redirect path?