Tiny URL (URL Shortener)
Tiny URL (URL shortener) is one of the most popular system design questions out there. On the surface it can appear as a very simple problem to solve, but it is possible to go deep on some of the scalability issues which many interviewers will expect.
This example will cover two solutions, a basic implementation and an advanced implementation. The basic implementation, has scalability issues but is worth noting, as discussing those flaws and a potential solution in the advanced implementation, will show a depth of understanding most candidates will not have.
This data model contains one table urls which has the following fields:
Given the simplicity of the of data, a classic RESTful API could be used. RESTful APIs are simple, widely used, stateless, and support caching which make it a perfect candidate for our system.
Our REST API will comprise of two main endpoints:
From the data model we can see that the data is not deeply nested or interrelated which would negate many of the benefits of using a GraphQL API.