Code Monkey home page Code Monkey logo

shorturler's Introduction

短链接系统说明

安装依赖

 npm install 

服务启动

nest start 

系统架构图

系统架构图

  1. 假定该系统为多读少写的系统,读写都会经过 redis,短链接对应关系最终存储在 mysql 中
  2. 使用了 murmurHash 算法进行短链接生成,生成后使用 base62 进行转码,保证两次 url 进来后生成的短链接是统一的
  3. 判断短链接是否重复,如果重复的话会在长链接后加上关键词,同时将关键词一并存储在 mysql 中
  4. 问题1:redis 在该项目中没有增加单元测试,使用了 redis 自带的 redisBloom 模块,所以在安装 redis 的时候需要安装 redisBloom 模块
  5. 问题2:没有设计短链接过期系统,后续考虑增加定时任务,清理最少引用的短链接

单元测试

kevkjh

单元测试覆盖了以下几个部分

  1. 判断是否为有效的长链接
  2. 转换长链接到短链接是否成功
  3. 两次存入长链接后,获得的短链接是一致的
  4. 判断非有效链接后返回异常

集成测试

8lrCxd

集成测试中主要测试了 web 端短链接的读,和长链接的写入。


压测

QBRLxt

测试了 120 qps 下,2400 个请求的情景下完成跳转的链接

| 状态 | 平均值 | | TP90 | 0.84 | | TP95 | 1.21 | | TP99 | 1.98 |


数据库设计

tLmGnP

shorturler's People

Contributors

penouc avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.