0
点赞
收藏
分享

微信扫一扫

Github好码推荐-Saku一个高性能的短链服务

胡桑_b06e 2022-05-27 阅读 63

Saku

Saku一个高性能的短链服务


整体设计

Github好码推荐-Saku一个高性能的短链服务_5g

 

短链请求过程&原理

Github好码推荐-Saku一个高性能的短链服务_3d_02

 

Features

  • 支持MurmurHash/DB Auto Incr 高性能生成短链

Quick Start

  • git clone
  • 配置

saku:
type: hash # 默认hash(基于Murmurhash),可选dbincr(数据库自增)

spring:
datasource:
url: jdbc:postgresql://postgres.host:5432/xxx
username: postgres
password: postgres
driver-class-name: org.postgresql.Driver

# 服务启动的端口
server:
port: 9555

  • 启动服务
  • 生成短链 /v1/saku/12s
  • GET Request

http://localhost:9555/v1/saku/l2s?url=https%3a%2f%2fmp.weixin.qq.com%2fs%3f__biz%3dMzIwMDY0Nzk2Mw%3d%3d%26mid%3d2650321066%26idx%3d1%26sn%3d0c1f15868b7d091736684a5b5a3639b4%26chksm%3d8ef5e4deb9826dc8f9374717ff1ecdbee434fc3470f6652693f7bebf9a58491a2ca8b381a57d%26scene%3d21%23wechat_redirect

  • return

9S5ggRpb3q6




  • 使用短链换取原URL:/v1/saku/s2l
  • GET Request

http://localhost:9555/v1/saku/s2l?surl=9S5ggRpb3q6

  • return

https://mp.weixin.qq.com/s?__biz=MzIwMDY0Nzk2Mw==&mid=2650321066&idx=1&sn=0c1f15868b7d091736684a5b5a3639b4&chksm=8ef5e4deb9826dc8f9374717ff1ecdbee434fc3470f6652693f7bebf9a58491a2ca8b381a57d&scene=21#wechat_redirect


TODO

  1. hash 方式冲突问题
  2. 分表
  3. 提供压测数据
  4. 支持多种数据库(mysql 、Oracle)

Feedback

​​gshiwen@gmail.com​​

License

​​Apache License 2.0​​

举报

相关推荐

0 条评论