A simple and efficient short URL conversion service based on SpringBoot
What is GeniusShortUrl?
GeniusShortUrl is an open source reactive service that converts long links to short links based on SpringBoot Webflux, which can quickly respond to link conversions and jumps.
- Blazing Performance
GeniusShortUrl is developed based on SpringBoot Webflux and can naturally receive more concurrent requests. And the project uses Caffeine cache, when the behavior of hitting the cache occurs, the response is extremely efficient.
- Easy To Use
GeniusShortUrl only needs very simple configuration, such as mysql database connection and cache configuration to run, which is easy to start quickly.
- Tiny Size
GeniusShortUrl is only about 39MB after packaging, and there is room for further optimization, which is also very friendly to memory usage.
Api
-
/url/shorten
Convert incoming long URL to short URL and cache. -
/url/jump
Jump from the visited short link to the long link (original URL), and extract the data from the cache if it hits the cache.
Design Overview
Getting Started
- Configure
/src/main/resources/application-prod.yml
, modifyr2dbc.url.r2dbc.mysql
related properties. - Execute the SQL script located in the
/resources/init-sqls/
path in the configured mysql database to initialize the database tables. - Modify the file
url-builder-config.yml
to configure the short chain prefix and suffix (the suffix will be used after a hash collision occurs when generating a short chain). - Configurable log output if necessary:
log4j2-prod.yml
. - Package the jar package and execute it. The production environment (that is, the operating environment corresponding to the file
/src/main/resources/application-prod.yml
) requires additional parameters spring.profiles.active=prod.