Functional Requirements:
Non Functional Requirements:
To Shorten URLs:
[POST] /api/urls/short
BODY: {
"longUrl": "www.google.com"
}
Response: {
"shortUrl": "www.domain.com/xyz34"
}
To GET Long URL from SHORT URL. If not available it will return 404.
[GET] /api/urls/long?url='www.domain.com/xyz34'
Response: {
"longUrl": "www.google.com"
}
Components
Hash Service: Responsible for generating unique hash per long url.
Redis: We will use redis for caching frequently accessed long url. We will use LRU algorithm to evict cache and any update or delete also remove the key from redis. If a key does not exist in cache then server will approach database for a table scan.
Load Balancer: Load Balancer will handle multiple server based on stateless RR algorithim.
Server: Server will process the request and communicate with Hash Service, Database and Redis. NoSQL: We will be using NoSQL database mongodb as our primary database. Our database will distributed. Since we are choosing availability over consistency we will return as soon as a user has written successfully in one database. We will also make sure one long url always lands on only one shard by using consistent hashing. So long Url will be the key the key here. We will be using Quorum based technique requiring majority vote (> N / 2). N will be always odd.
Components: