[POST] /create
[GET] /[id]
ShortenedURL:
Client -> API Gateway -> Cache or server -> DB
For adding a new URL
1) User enters original URL via client
2) Client sends the original url to [POST] create
3) An ShortenedURL is generated.
4) The UI shows the shortened URL
For accessing a new URL
1) User enters the site via the client
2) The request goes to the API gateway and the cached is checked. If the cache is empty, check the database
3) If the database is empty, return a 404.
4) However, if its found in either cache or database, a 203 is returned and user is redirected to the original URL
For the API gateway, there will be a cache used. Redis is ideal because it is in-memory database which is faster than RAM, its a key-value store.
A SQL database is used because there is unlikely any changes in the schema, and capturing single queries are faster with indexing.
SQL vs NoSQL
Redis vs Memcache
A higher influx of users are way above the estimated number of users. As such, the server is overloaded.
Not only that, as there are too many records, it would be expensive for the database to scale.
For the high influx of users:
For the database: