Functional requirements
- Short url generation: Generate unique shorter alias of the given URL
- Redirection: System should be able to redirect the user to the original URL
- Deletion
- Update
- Expiry time
<aside>
💡 As a design choice, we don’t reuse the expired short URLs. Since we don’t reuse them, why do we need to delete them from our system?
Answer: So far, we’ve kept the default expiration time to five years. If we relax that limitation and start saving the records forever, our datastore’s search index will grow without bound, and querying time from it can add noticeable latency.
</aside>
Non-Functional Requirements
- Availability: Highly available.
- Readability: The short links generated by our system should be easily readable, distinguishable, and typeable.
- Unpredictability: From a security view, the shorts links should be unpredictable. This ensure they are not serially produced, eliminating the guessing of the short URLs.
Building blocks
- Databases: Store the mapping of URLs
- Sequencer: Will provide unique IDs that will server as a starting point for each short URL generation
- Caches: Store frequent short URLs relates requests
Database
short URL |
string |
long URL |
string |
expiry |
Date Time |
creation |
Date Time |
Since the data is not strongly relational, NoSQL databases such as Amazon DynamoDB, Apache Cassandra, or MongoDB will be a better choice here, if we do decide to use an SQL database then we can use something like Azure SQL Database or Amazon RDS.