In Twitter, Weibo, you have charactor limit. Also normal URL will contain some invalid ASCII code that you cannot put into the content.
So a lot of company has its own Short URL
Example: http://t.cn/RGKGR3T
Design A System that can generate this Short URL
UUID
MD5
Are these too long? Could we find a better way?
Think about the requirement
one URL could be used released after some day
We do not generate a short URL everytime, we just lookup the table
Restful service
Restful API
Short URL -> Long URL, time
Pretty Easy? If we have a high QPS?
Relational Database: Oracle, MySql
Non-Relational Database (NO Sql): MangoDB, CouchDB, Couchbase, Redis
RDBMS(Relational Database Management System)
NoSQL (Not Only SQL)
WE could just use NoSQL
Reason: we do not have complicated query to fetch data, we only need original URL and short URL (timestamp maybe)
How to update the Store?
How to remove them?
short -> Long
short -> time
time -> short
Is it okay?
If we could stretch the time
short -> Long
short -> time
Daily/hourly data purge job
Relational Database cannot handle high reading QPS
NOSQL has a lot limit in relation and maintenance
So sometimes we just hybrid them together
For common get queries, we store them in NOSQL
For specific queries and write operation, we still use RDBMS
How to update NOSQL? Database Listener
Database: Relational and NoSql -> consider to use which one
Network: Apache, Tomcat, etc -> Rest API, JSON
Distributed System: Load balancing, Sticky Session
Security: HTTPS, Encryption/Decryption