Basic understanding of URL shortener Service/Tiny URL Creation Service
Let’s take an example: Suppose, we want to shorten this page through our URL Shorteners Service:
After shortening the url: http://aegistiny.com/a8uhs
Note: The tiny /short URL is nearly one-third the size of the actual URL.
Requirement Anatomy
Our URL shortner tool should be capable of meeting the following requirements:
Understanding the Requirements:
  1. Here, we will give the privilege to the user to choose their custom short URLs from their original long URL. Our system should generate a tiny URL which is the unique alias of the original URL (input). This is called a tiny URL or a short link which is very short and can be easily utilized in applications very easily.
  2. Once user gets the short links from their original URL, then users will be able to invoke that tiny URL and in our service, we have to take care of redirecting that tiny URL (Short link) to the actual long URL.
  3. When providing the users to choose the short links for a given URL, then we should also allow users to specify the expiry time so that till that period that specific short link/tiny URL will work and after that, the link will get expired.
  4. Our system should support high availability and high scalability. Our system should be capable enough to handle the traffic (millions of requests) for URL redirection with low latency support.
Estimating the Capacity for our System
Traffic estimates:
Storage estimates:
Memory estimates:
Backend APIs
Payloads for Generating the Tiny URL/Short URL:
Request URL format:
Explanations of the Headers:
Return Type: (JSON)
System Designing Process:
The solution that we should implement here is the URL encoding of the actual/original long URL.
Sample code for reference:
Mac mac = Mac.getInstance(“HmacSHA256”);
              SecretKeySpec hashKey = new SecretKeySpec(original_url.getBytes(),“HmacSHA256”);
              mac.init(hashKey);
Finding the Original URL from the key Serial Number stored in Database
Designing Database Schema:
Database Schema:
Caching Requirement:
Updating Cache:
Clearing Cache
Scalability and Loadbalancing with TLS Security:
Health Checks:
Application Security:
Cleaning Up Database:
Conclusion
In this context, the requirement is designing a URL shortener service that will shorten any kind of long URL. All the design step we have mentioned so that you can be able to implement the requirement with minimal effort.