Code Monkey home page Code Monkey logo

red-envelope's Introduction

简介

红包秒杀系统:模拟红包秒杀时的高并发场景,学习并实现业界成熟的秒杀架构。

调研设计笔记

启动

1.安装并启动rocketmq

http://rocketmq.apache.org/docs/quick-start/

nohup sh bin/mqnamesrv &
nohup sh bin/mqbroker -n localhost:9876 &

2.安装并启动reids

https://redis.io/download

./src/redis-server

3.启动本项目

运行RedEnvelopeApplication main方法

4.创建红包

POST http://localhost:8080/red-envelope/create

请求body:

{
	"user": "lewiszlw",
	"type": "ORDINARY",
	"amount": 10000,
	"size": 5
}

5.抢红包

GET http://localhost:8080/red-envelope/grab?envelopeId=1&grabber=lewis

注:envelopeId 为红包id,grabber 为抢红包者

6.验证结果(对账)

GET http://localhost:8080/red-envelope/verify?envelopeIds=3,4,5,6

压测

1.安装locust

https://docs.locust.io/en/latest/index.html

pip3 install locustio

2.修改locustfile.py

修改locustfile.py中的ENVELOPE_ID为创建好的红包id

3.在项目目录下执行命令

locust --host=http://127.0.0.1:8080

4.打开Locust web界面,输入指标开始压测

http://127.0.0.1:8089

ps.可以开多个slave来提高RPS (Requests per second)

red-envelope's People

Contributors

lewiszlw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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