Concept (data)
shortUrl
RESTful API - api/v1/
Deep dive into 2-3 key components. Explain how they work, how they scale, discuss tradeoffs, capacity, and any relevant algorithms or data structures.
Router: it will route user query based on the request operation type. For read operation, it will route the user to the nearest API endpoint based on geo location. For write operation, it will route the request to write API endpoint.
Read API: it's backup by a microservice (so it can scale). It's a stateless service where it will get the map from cache, if no cache hit, then query database directly and update the cache. For better query experience, we can add GraphQL support in the API.
Write API: it's backup by a microservice (for scale) as a stateless service. It will operate database operation per request.
Map cache: The map cache can be any cache service. it can be in-memory cache or cache with storage (e.g. Redis). Cache records use TTL to balance between cache hit and legacy record.
Database: For this case, it might not make sense to use relational database since we don't have complex data structure. We can use common document db to store the url map records. Based on the query, we will have to turn on indexing of id/code. The database should have replica for data recovery.