APIs will be defined in two ways:
The /generate pathway will direct the user to a home page that allows them to generate a new shortened URL. The base URL will simply redirect them to the representative URL of the shortened version that was submitted.
The /generate pathway will internally call to /generateURL which will host the logic to randomly generate an ID that will be used for the shorted URL.
Client hits the CDN which directs them to our Load Balancer. This Load Balancer will distribute the workload on a round robin basis to one of multiple servers. The API gateway will dictate which service to use based on the HTTP request, and will manage rate limiting so that our system maintains resiliency and is not overloaded by requests. The shortener service will be where a user can create a shortened URL. This page will ask the user for information such as the Long URL and return a shortened URL with a randomly generated unique number. It will run a lookup to our database to make sure that the Short URL is not in use. If it is available, it will add this Short URL to the database and return a verification to the user. The redirect service will take the shortened URL and look first to Redis to see if the URL is cached. If there is a cache miss, we will look into a database to find the long URL. This long URL will then be returned to the client.
The Load Balancer will use a Round Robin approach to distribute workloads. This will be done to evenly distribute workloads as they come in.
Redis will be used to cache frequently visited sites. Redis will also use an LRU policy to evict old URLs, and a TTL of one week.
The shortener service will randomly generate a 7 digit number. ID This ID will be cross-referenced to the database to ensure it is not already in use. If it is, the shortener service will randomly generate a new 7 digit number ID.