GithubHelp home page GithubHelp logo

lsy1973 / seckill Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 1.98 MB

项目描述:一个基本功能完整的秒杀项目。登录用户可以查看实时库存,并且选择商品进行秒杀操作。 项目角色:后端各模块的开发;数据库表的设计。 核心功能的实现: 1. 使用通过对登录用户颁发凭证,记录登录用户的登录状态。 2. 对于频繁访问的数据,比如用户的基本信息,使用Redis作为本地缓存,提高服务器性能。 3. 使用Redis进行了预减库存的操作,减少频繁秒杀对于数据库的多次访问。 4. 项目集成了RabbitMQ,实现多用户场景下的异步下单,同时使用了ThreadLocal保证线程安全。

Java 76.51% Lua 0.09% JavaScript 1.30% HTML 22.10%

seckill's Introduction

项目说明

  1. 项目框架搭建
  • SpringBoot环境搭建
  • 集成Thymeleaf,RespBean
  • MyBatis
  1. 分布式会话
  • 用户登录
    • 设计数据库
    • 明文密码二次MD5加密
    • 参数校验+全局异常处理
  • 共享Session
    • SpringSession
    • Redis
  1. 功能开发
  • 商品列表
  • 商品详情
  • 秒杀
  • 订单详情
  1. 系统压测
  • JMeter
  • 自定义变量模拟多用户
  • JMeter命令行的使用
  • 正式压测
    • 商品列表
    • 秒杀
  1. 页面优化
  • 页面缓存+URL缓存+对象缓存
  • 页面静态化,前后端分离
  • 静态资源优化
  • CDN优化
  1. 接口优化
  • Redis预减库存减少数据库的访问
  • 内存标记减少Redis的访问
  • RabbitMQ异步下单
    • SpringBoot整合RabbitMQ
  1. 安全优化
  • 秒杀接口地址隐藏
  • 算术验证码
  • 接口限流,使用ThreadLocal保证线程安全

使用说明

服务器部署 登录页面:http://124.220.207.187:15327/login/toLogin

本地 登录页面:http://localhost:8080/login/toLogin

登录之后,每个用户只能秒杀一件商品,暂时没有实现支付功能

代码生成器:https://gitee.com/guizhizhe/code-generator.git

  1. 在本地测试正常,但是部署到服务器时,登录之后,页面中的user信息无法传递 经过排查,发现是部署在服务器上时,登陆时不生成cookie

最终的问题解决:

原来的代码是:

if (!"localhost".equals(domainName)) {
    cookie.setDomain(domainName);
    }else{
        cookie.setDomain("localhost");
}

这样会造成一个问题,服务器的完整ip地址是192.168.0.0,而这段代码只能获取到168.0.0

解决方案:

Pattern pattern = Pattern.compile("[0-9]+.*");
Matcher matcher = pattern.matcher((CharSequence) serverName);
boolean result = matcher.matches();
if(result)
domainName=serverName;

seckill's People

Contributors

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