Requirements


Functional Requirements:


  • Create a short URL for a given long URL.
  • Return the long URL associated with a given short URL.



Non-Functional Requirements:


  • Low latency on _read_ path (adding new urls MUST NOT slowdown lookup)
  • Write path is less frequent, so write performance is secondary


API Design

POST /alias {"url": string}

Returns {"url": string, "slug": string}


GET /alias/{slug}

Returns {"url": string}


High-Level Design

Clients calls API server.

API server looks up slug in database

Lookup is based on indexed field, so that btree can be used.




Detailed Component Design

Server: thin microservice, maintains connection pool to database

Database: read replicas, single write primary for write path