![]() If we replicate the data 3x, our total storage need is 300TB. If we assume each URL entry in database occupies 1K bytes of storage, the amount of data we need to store over 3 years is 10^14 bytes of data. Hence, we need to store 10^11 short URL entries. Lets estimate storage capacity for 3 years. In one day we are generating 10^5 (1 million seconds per day) * 10^3 (1 K per second write requests) requests.The requirements state that we are expecting 1000 write requests and 1 million read requests per second. See an article that I wrote on rate-limiting here. In addition, we can apply rate-limiting based on user session or id to prevent certain clients from abusing the service. User requests can be denied when the number of short URLs by a user increase beyond a certain threshold. We can allocate to a user a certain maximum number of short URLs that they can create. Void deleteShortURL(sessionId, shortUrl) Prevent Over Use or Abuse Return: Return success or failure error code depending on whether the request was successful or otherwise. ShortUrl: A string representing the short URL. String updateShortURL(sessionId, originalLongUrl, customShortUrl, DateTime expiryTime=null)ĭeleteShortUrl: A DELETE request to delete a given short URL. Where the long URL pointed to by the short URL can be modified.ĬustomShortUrl: A string representing the short URL. UpdateShortUrl: A PUT request to update a short URL. String createShortURL(sessionId, originalLongUrl, customShortUrl=null, DateTime expiryTime=null) Otherwise, on failure return an error code. OriginalLongUrl: String representing the original URL that needs to be shortened.ĬustomShortUrl: An optional string representing the short URL.ĮxpiryTime: An optional date representing when the short URL will expire. SessionId: String representing the session id of the user that’s requesting for the session to be created. The requests can be served over a REST API.ĬreateShortUrl: A POST request to construct a short URL. It will provide the ability to redirect a short URL request to the original long URL. The purpose of a URL shortener is to transform a long URL into a short URL. Should be able to serve 1,000,000 QPS read requests.Should be able to serve 1,000 QPS write requests.99p request serve time for write requests should be under 100ms.99p request serve time for read requests should be under 20ms.Redirect traffic requests for a short URL to the original URL.Links will expire after a timeout period that can be user specified.Pick a custom short url for a long url. ![]() Should be possible to generate multiple short urls for the same long url.Short Url creation, update and delete requests.Will cover the below items in this design:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |