Git Product home page Git Product logo

wangjia2016 / platform-open Goto Github PK

View Code? Open in Web Editor NEW
14.0 2.0 5.0 184 KB

本项目基于SpringCloud &SpringCloud Alibaba ;可以作为微服务架构脚手架,整合了nacos、rocketmq、sentinal、feign、redis、redisson、jjwt、mybatis等常见微服务组件;包含分布式锁、RocketMq(事务消息、延时消息、普通消息)、线程池、常用设计模式等技术的使用场景。同时也包含商城秒杀功能设计、优惠券体系设计、权限系统设计、订单&商品系统设计、微信支付等业务功能。

Java 100.00%
springcloud-alibaba rocketmq redisson spring-cloud-gateway sentinel nacos jwt feign redis degisn

platform-open's Introduction

本项目持续完善中... 具体技术 详解&业务设计,参见WIKI

1.项目说明

  • 本项目基于SpringCloud Hoxton.SR8 &SpringCloud Alibaba 2.2.3.RELEASE 最新版;
  • 关于SpirngCloud、SpringCloudAlibaba、SpringBoot 三者的版本依赖关系 参见SpringCloud官方文档
  • 本项目可以作为微服务架构,整合了nacos、rocketmq、sentinal、feign、redis、redisson、jjwt、mybatis等常见微服务组件
  • 网关采用Spring Cloud Gateway 是另外一个单独的项目
  • 本项目以商城秒杀下单为例,使用Redission分布式锁控制库存扣减,RocketMq进行异步、削峰处理、以及用事务消息实现分布式事务等
  • 基于Redis的幂等性方案
  • 全局统一异常处理
  • 业务:秒杀&优惠券&微信支付&商品配置&订单
  • 设计模式:工厂模式、策略模式、模板方法、状态机模式等

2.秒杀介绍

  • 秒杀的难点
    • 瞬时流量
    • 防止库存超卖
    • 吞吐量
  • 流量预估
    • 如何预估秒杀峰值?
    • 每个订单对象大小估算?
    • 带宽估算?
  • 优化
    • 秒杀下 JVM如何优化
    • 如何快速定位线上问题
    • 如何压测?

3.秒杀架构演变

  • V1.0 单机环境下早期采用数据库的悲观锁 for update、乐观锁等进行控制 or ReentrantLock synchronized
  • V2.0 分布式环境下 采用分布式锁进行控制库存扣减
  • V3.0 微服务高并发环境下,采用redis+mq 多级缓存、异步、削峰

4.秒杀解决方案

  • 业务尽可能简单,能取缓存就从缓存取(可以是多级缓存),减轻mysql的压力
  • 采用mq异步,削峰,控制入库的数量
  • 流量拦截,尽可能将请求拦截在上游,比如参数校验,黑名单校验等业务校验
  • 前端
    • 秒杀倒计时(甚至有部分电商,各用户看到的倒计时都不一样)
    • 页面静态化
    • 防止重复点击
    • 隐藏url
  • 网关拦截
    • 校验token
    • 接口防刷 (防黄牛 - 风控机制)
    • 幂等性校验

5. 项目架构图

系统架构

6. 技术栈

  • SpringCloud Hoxton.SR8
  • SpringCloud Alibaba 2.2.3.RELEASE
  • nacos
  • open feign
  • Ribbon
  • Redis
  • Redisson
  • RocketMq 4.7.1
  • Sentital
  • ElasticSearch
  • Spring Cloud Gateway
  • JWT
  • Mybatis
  • mybatis-plus 3.4.0
  • jackson
  • HikariCP
  • kaptcha
  • Swagger

7. 工程结构

基于maven的多module模块,如果要加入其它微服务模块,直接添加即可

8. 秒杀业务时序图

参数校验-->redis库存预扣减-->发送下单消息到MQ-->提示订单处理中 订阅者-->拉取下单消息-->真实库存扣减…&下单入库

9. 业务功能模块

  • 秒杀业务
    • 秒杀场次列表 - 待实现
    • 秒杀活动,一个活动包含秒杀起止时间、活动名称等
    • 秒杀场次,一个场次包含多个秒杀商品 - 待实现
    • 秒杀商品,一个秒杀商品可以被多个秒杀场次关联
  • 支付
  • 通知
    • 待支付提醒
    • 订单取消提醒
    • 支付提醒
    • 发货提醒
  • 支付回调
  • 订单状态机 -状态模式实现

10.系统流程

11.开发者规约

  • 参考 阿里巴巴java开发者规范 Java开发手册嵩山版

12.压测结果

使用jemeter进行压测

13.部署说明

先导入数据库脚本 修改application.yml里面的mysql、redis、nacos、rocketmq链接地址 启动相应的组件

14.许可协议

15.功能截图

  • 前端效果 前端效果 前端效果

platform-open's People

Contributors

wangjia2016 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

platform-open's Issues

DATABASE

Can you upload the SQL statement. Thank You.

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.