秒杀
定义
秒杀是指商家对商品在规定的时间点内进行促销活动,大量的用户在秒杀页面进行抢购
在同一时间,有大量的请求购买同一个商品,且需要完成支付!(大批量的读与写)
秒杀中使用的技术点
整体的架构需求
- 因为会涉及大量的并发读和并发写,所以必须支持高并发访问. 解决方案:热点的发现隔离,动静分离,请求削峰与分层过滤,服务端的极致优化
- 会存在超买超卖的现象,在大并发的更新中,保证数据的一致性
框架的搭建
pom.xml
<!--MybatisPlus的网址:https://baomidou.com/pages/b7dae0/#使用教程-->
<!--springBoot依赖-->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.4</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<dependencies>
<!--thymeleaf组件-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<!--web组件-->
<dependency>
<groupId>org.springframewor