Write path:
Read path:
There are two separated servers:
Both services access the database, that contains entries with shortend and original urls. The database.
The backoffice and retrieval services are stateless, so they can scale separately. The most critical is database. It can be some relational database replicated multiple times. The database also can use sharding to improve scalability.
To assure low latency on url retrieval, shortened url needs to be propagated on multiple database replicas. To achieve that, the master database instance that handles writes, the creating operation needs to assure, that all data are synced to replicas - then it can return response with new entry.
Master database also is responsible for generation next shortened url.