I create an side project to implement TinyURL on my own with freedom in my technology choice.
From draft version to final version, performance proved to able to handle
21k read request per sec and
14k create request per sec with single instance.
Functional Requirement (* - Mandatory)
- Create unique shorten-url from an alias creation request
- Redirect the access from shortenned-url to target URL
Non-Functional Requirement (Not Mandatory, freedom part)
Note: In this project, I try to test some technology to make it fun, fast, stable, durable, and scalable
- Able to handle thousands create request per second for single instance
- Able to handle thousands access request per second for single instance
- Able to fast, and effortless detect invalid access request
- Create a performance test for prove the system durable, realiable, and scalable
First version:
- Simple spring boot with mysql, support two api:
- - POST /api/alias/create
- - GET /{alias}
- which are satisfy the functional requirement stated above.
- Implement NanoId for create random alias
- Implement Snowflake ID generation and Base58 convertion from SnowflakeID to character for newly created alias
Second version:
Add primary cache
- using LRUCache (capacity 1000) implements from HashMap internally an instance, for fastest accessible
- Add secondary cache using Redis with timetolive 1 day for durable and scalable cache support
Third version:
- Implement bloomfilter base on Redis version 8.x for fast no-exist alias check.
- Implement write-back every 2 sec for caching created request, empower the capacity for fast creation alias.
- Implement hibernate batch create, update, sequence allocation for fast saving/persisting
Final version:
Add Grafana, Prometheous, Mysql-Exporter, Redis-Exporter for monitoring
Add K6 script for complex performance test scenario
Add WRK script for extreme performance test scenario
Result:


Top comments (0)