List the key functional requirements for the system (Ask the AI for hints if stuck).
A user should be able to shorten a url
A user should be redirected to their actual website within an acceptable time period. Same as if they were to use their own link
A user should be able to regenerate a tiny url
List the key non-functional requirements (performance, scalability, reliability, etc.)...
High availability- lots of people rely on these short links so what should we set the availability at? 99.99? how many 9's
Achieved through horizontal scaling - redundancy across regions and load balancers
we also want low redirect latency- what number can we put on it?
<50ms p99 redirect time?
Achieved through
Estimate the scale of the system. Consider daily active users, read/write ratio, storage requirements, bandwidth, and any relevant QPS calculations...
daily active users - 50,000 users
with 50,000 DAU, lets say each user creates 2 urls/day on avg.
That gives you:
Write: 100K URL creations/day --> 1.2 writes/second
Read: 100times that so 120 reads/second
read/write ratio - reads outweigh writes in this type of system.
what should we assume? 1:100?
storage requirements
if each mapping is roughly 500 bytes(ID + long URL + metadata)
bandwidth - mostly https redirects outbound
QPS calculations
Define the APIs expected from the system. This is your chance to analyze and define the read and write paths so that you can come up with the high-level design...
How should we describe processes such as redirection in API paths?
POST /tiny?url=someurl
GET /tiny?url=someurl
PATCH /tiny?url=someurl
Describe the overall system architecture. Identify the main components needed to solve the problem end-to-end. Use the diagramming tool to create a block diagram.
Define the data model. Identify the main entities, their attributes, and relationships. Consider the choice of database type (SQL vs NoSQL) and justify your decision based on access patterns...
Deep dive into 2-3 key components. Explain how they work, how they scale, discuss tradeoffs, capacity, and any relevant algorithms or data structures.