Giter Site home page Giter Site logo

seckill's Introduction

高并发的瓶颈在数据库

减少数据库访问

思路:
1.系统初始化,把商品库存数量加载到Redis
2.收到请求,Redis预减库存,库存不足,直接返回,否则进入3
3.请求入队,立即返回排队中
4.请求出队,生成订单,减少库存
5.客户端轮询,是否秒杀成功



项目框架

1.Spring Boot环境搭建
2.集成Thymeleaf,Result结果封装
3.集成Mybatis+Druid
4.集成Jedis+Redis安装+通用缓存Key封装

页面优化技术

1.页面缓存+URL缓存+对象缓存
2.页面静态化,前后端分离

接口优化

1.Redis预减库存减少数据库访问
2.内存标记减少Redis访问
3.RabbitMQ队列缓冲,异步下单,增强用户体验

安全优化

1.秒杀接口地址隐藏

秒杀开始之前,先去请求接口获取秒杀地址
思路:

  1. 接口改造,带上PathVariable参数
  2. 添加生成地址的接口
  3. 秒杀收到请求,先验证PathVariable

2.数学公式验证码

点击秒杀之后,先输入验证码,分散用户请求
思路:

  1. 添加生成验证码的接口
  2. 在获取秒杀路径的时候,验证验证码
  3. 使用ScriptEngine

3.接口防刷

对接口做限流
思路:

  • 用拦截器减少对业务侵入

seckill's People

Contributors

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