Low latency, scalability, reliability, High availability
It'll be Rest API like v1/makeItTiny Post request which responds with a Base64 encode ID for that url like a245B which represents our given url in post request which then can be accessed by hitting ourDomainName.com/Base64encodedString
We'll also may another API which will return the required url based on Base64 encoded string provided example /encodedString get request responds with required url + timestamp for expiry (although not necessary as we are only required to redirect to the original url and this API will only be used internally for may be cleanup of old expired urls)
v1/base64encodedTinyUrl -> response will be 3xx redirect to original url
v1/tinyUrl/analytics -> get response for analytics on url (possibily only internal use)
HLD looks like client connecting to our service by requsting a url creation url or redirect url, the request goes to CDN (request is served if cached in cdn) then it hits load balancer which based on the location of the client and server loads redirect the request to one of the API gateways, now API gateways (multiple regions have their own API gateways or services) have to caches 1. Redis L1 cache and 2. local API service cache, in case of cache miss API gets the response from DB, populate the cache then return the response for the request from the database, so basically design is request -> CDN -> Loadbalancer -> API gateways (L1 redis cache + L0 API local cache) -> Database
Database here can be postgres relational Database
API service also connects to ID generator service which can be scaled independently, this ID generator uses ID from DB to generate unique base64 encoded string, also if our system is highly distrubuted then ID generator can use regionID+machineID+timestamp to generate a unique string
Also we'll have ansync analytics service which will look at url analytics about urls + entire system, things like url hit rate etc.