RESTFUL
GET: api/v1/get_long_url?url=
POST: api/v1/generate_short_url?url=
client can submit long url to generate short url
each record will contain a record id, short url and long url
For generate short url:
For redirect to long url:
a. use hashcode to generate (hash collision possible)
b. Use base 65 (or larger number to contain symbols) to generate a number from the long url , easier to check the long url
c. use snowflake id to contain timestamp in the record id (easier for expire the record)
2.Base on QPS, read is about 1k QPS
write is about 50 QPS
One SQL DB machine is enough.
But we can provide a cluster (2 or 3 master and multiple slaves SQL database machines) to enhance availability and reduce processing time)
We can have a cache and expiration period for hot spot urls
3 DB size:
50 * 100 byte * 100,000 per day = 0.5 GB per day
1 yr = 15 Gb * 12 = 180 GB
10 yr = 1.8 TB
a.
b.
will not use scan, but build index on short/long urls for quick check if they are in database.