Giter Club home page Giter Club logo

seckill's Introduction

简介

这是一个秒杀项目

项目内容

1.项目框架搭建

  • SpringBoot环境搭建
  • 集成Thymeleaf
  • MyBatisPLus自动生产代码
  • 封装统一返回结果CommonResult

2.分布式会话

  • 用户登录
  • 共享Session优化登录

3.功能开发

  • 商品列表
  • 商品详情
  • 秒杀
  • 订单详情

4.系统压测

  • JMeter配置
  • 自定义变量模拟多用户
  • 利用脚本生成多用户信息
  • 正式压测

5.页面优化

  • 页面缓存+URL缓存+对象缓存
  • 页面静态化,利用ajax异步请求后端接口
  • redis缓存优化静态资源

6.接口优化

  • Redis预减库存减少数据库的访问
  • 内存标记减少Redis的访问
  • RabbitMQ异步下单

7.安全优化

  • 秒杀接口地址隐藏
  • 算术验证码
  • 限流算法(计数器、漏桶、令牌桶)

8.超卖问题

  • 唯一索引
  • 数据库行锁
  • Redis分布式锁,减少库存
  • RabbitMQ异步下单
  • 前端轮询获取秒杀结果

软件架构

技术 版本 说明
Spring Boot 2.1.2 框架
MySQL 5 数据库
MyBatis Plus 3.5.1 持久层
Swagger 1.5.24 文档
Redis 4.0.11 缓存
RabbitMq 2.1.2 消息队列

使用说明

sql:建表语句、初始化数据和回滚压测数据脚本

分支说明

项目共有三个分支:

1.master分支,包括了项目的登录功能、商品列表、商品详情、秒杀、订单详情等,同时使用Redis缓存对页面、热点对象进行优化,通过ajax技术异步获取后端接口请求,并将接口数据动态渲染到前端,相比用Thymeleaf引擎渲染数据到html再全局展示的方式,速度更快。

秒杀系统的基本功能实现了,但存在大量用户下单时,库存超卖的问题,以及qps过低的问题。

2.redis预减库存+消息队列削峰分支,通过redis预减库存的方式,将用户秒杀和生产订单解耦,并通过消息队列方式通知减存库、下单等操作保证高并发情况下系统的健壮性。使用lua脚本减库存,保证了操作的原子行,并利用前端轮询获取秒杀结果,保证了Redis和数据库的一致性。

3.安全优化分支,通过秒杀接口隐藏以及验证码等手段,防止接口被刷单,通过自定义注解实现接口限流。

seckill's People

Contributors

xqxls avatar

Watchers

 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.