思路:
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队列缓冲,异步下单,增强用户体验
秒杀开始之前,先去请求接口获取秒杀地址
思路:
- 接口改造,带上PathVariable参数
- 添加生成地址的接口
- 秒杀收到请求,先验证PathVariable
点击秒杀之后,先输入验证码,分散用户请求
思路:
- 添加生成验证码的接口
- 在获取秒杀路径的时候,验证验证码
- 使用ScriptEngine
对接口做限流
思路:
- 用拦截器减少对业务侵入