Giter Club home page Giter Club logo

jseckill's Introduction

jseckill

电商秒杀程序, 乐观锁,Spring Boot.
如果该项目对您有帮忙,您可以右上角'star'支持一下,谢谢!

演示地址

👉 http://jseckill.appjishu.com


Star me on GitHub
🐱 https://github.com/liushaoming/jseckill

源码解析

👉 源码解析文档

演示

  

技术栈

1.Spring Boot
2.MyBatis
3.Redis
4.Thymeleaf
5.Bootstrap
6.RabbitMQ
7.zookeeper实现分布式锁

高并发优化手段

1.使用Google guava的RateLimiter来进行限流
2.减库存时,在同一事务内,先"插入记录",再"更新库存", 能有效减少行锁的作用时间.
数据库更新操作,采用乐观锁,提高并发性
3.暴露秒杀接口,暴露信息,作为不常更新的热点数据,贮存到Redis里
4.前端静态文档部署到CDN, 缺少资金的公司可以选择动静分离
动静分离:把静态资源(js,css,图片)直接部署放到nginx, 动态服务还在原有的tomcat/SpringBoot里。
5.Java应用部署多个集群节点,之间使用nginx做负载均衡和反向代理,提高客户端的并发数
6.RabbitMQ异步处理秒杀记录

秒杀过程

1.RateLimiter限流。 并发量大的时候,直接舍弃掉部分用户的请求
2.Redis判断是否秒杀过。避免重复秒杀。如果没有秒杀过,
在Redis操作前分布式加锁 Redis秒杀(减库存,并记录已秒杀成功者的userPhone)
然后分布式解锁
3.发送秒杀记录到RabbitMQ,并且马上返回结果到客户端
4.监听RabbitMQ的队列消息, 一条条地读取消息后,操作数据库。插入秒杀记录和减库存。
并手动ACK队列
详情见源码文档


TODO
进一步的优化:等到CountDownLatch每积累20个,才去操作redis, 直接decrby 10

未完待续

演示地址
👉 http://jseckill.appjishu.com

现在工作略忙,后面抽空完善技术文档
📌⭐⭐⭐❤❤❤

GitHub地址,路过的帮忙点个星星star,谢谢😊

🐱 [https://github.com/liushaoming/jseckill](https://github.com/liushaoming/jseckill)

有代码改进优化的建议的统一在Issues里面提
加群讨论

微信公众号

jseckill's People

Contributors

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