Loading...
100 Million new URLs/month.
100:1 Read/Write ratio.
Storage: 3 Terabytes over 5 years.
POST /api/v1/shorten
GET /{shortAlias}
What the box asks for: Describe the overall architecture and identify main components. What you should type in this box:
System Architecture & Request Flow
Component Breakdown:
What the box asks for: Define the data model, entities, and justify SQL vs NoSQL. What you should type in this box:
Database Choice: NoSQL (e.g., DynamoDB or Cassandra) Justification: We are storing billions of simple, independent key-value pairs (Short URL -> Long URL). We do not need complex relational joins or strict ACID transactions. We need massive horizontal scalability, high write-throughput, and high availability, which NoSQL handles perfectly.
Schema (URL_Mapping Table):short_url_hash (String, Partition Key) - e.g., "b9Lq"original_long_url (String)created_at (Timestamp)expires_at (Timestamp)user_id (String - optional for analytics)The Shortening Algorithm: Base62 Encoding
To generate the short link, we will use Base62 (A-Z, a-z, 0-9).
A length of 7 characters gives us (~3.5 Trillion) unique combinations, easily covering our 6 Billion URL estimate.
Collision Prevention Strategy:
To ensure two identical short links are never generated at the same time, we will use an offline Key Generation Service (KGS).