GithubHelp home page GithubHelp logo

skill's Introduction

基础秒杀项目简单架构设计

所用技术: 前端 layui+jquery 后端 springboot +redis+rabbitmq+thymeleaf+jsr303 数据库 mysql5.6

项目也用了分布式缓存和分布式session 以及分布式缓存配合本地缓存使用

对于超卖等问题的解决 update .... where id=.. and stock>0 利用了数据库的行锁 同时对秒杀表的uid_goodsid 做了唯一索引

当然 你也可以利用redis 分布式锁解决

核心秒杀架构:

系统初始化时 加载库存进redis存储
秒杀请求到时 做一些业务检查 或重复性检查再对redis预减库存	减少数据库访问
本地Map内存标记缓存以减少对redis的访问
异步下单 请求入队 立即返回排队中
请求出队 生成订单 减少库存 (在一个事务中)若失败后 注意需对预减的库存加回去 以保证内存的库存可数据库中的一致性
客户端轮询 是否成功

安全方面的考虑:

数据加密
秒杀地址隐藏 动态
限流防刷限制
数学公式验证码校验

skill's People

Contributors

liangbaika 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.