A: Create short alias URL from original URL
B: reroute short alias URL to original URL
latency:
we need B requirement (reroute) to be at most 10 ms
A can be slower, maybe 1 second
scalability:
300,000 creates a day
1,500,000 reroutes a day
availability:
reads are the most important
consistency:
eventual consistency is good enough
4200 bytes * 300,000 per day = 1,240 mb
50 terabytes for 10 years
createAlias(url: string, user_id: string (uuid), experation_time: string? = None)
reroute(alias)
we will use a No-SQL because it's more performant, the performance-sensitive data is not relational
alias:
id: 8 byte string PK
URL: 2048 character string - up to 4096 bytes SK
created_at: 16 byte string
user_id: 16 byte uuid string
user:
id: 16 bytes uuid PK
created_at: uuid
we have an api gateway to route the clients request (reroute or createAlias)
posting the alias:
getting the alias
client can
the "post alias" will create the alias, we will use a random id to create the alias, or if the user submits one it can be used as well.
generating the alias ->
if the api gateways is a single source of failure
job queue has added complexity
cache has added complexity
if we expand user functionality then we might favor a relational database (SQL) for their information.