Skip to content

This is a project for demonstrating the second-killing activity typically used by e-commerce shop promotion.

Notifications You must be signed in to change notification settings

pizhigang/demo-gift

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is a project for demonstrating the second-killing activity typically used by e-commerce shop promotion.

It is based on Spring Boot, and making use of redis for the persistence.

  • use Redisson AtomicLong to filter the 1st layer - the number of requests can be pass thourgh is not more than the count of the gift.
  • use Redisson distributed Lock to filter the 2nd layer - only the use who has not been got gift can participate the acitivity, that's, can pass through to the persistency layer.

##1. install redis wget http://download.redis.io/releases/redis-3.0.3.tar.gz
tar xzf redis-3.0.3.tar.gz
cd redis-3.0.3
make
src/redis-server
# another console
, to clean up the database for re-run the test, PLEASE NOTE THAT IT WILL EMPTY ALL OF THE DATABASE. src/redis-cli flushall

##2. install wrk git clone https://github.com/wg/wrk.git
cd wrk
make

##3. run demo git clone https://github.com/pizhigang/demo-gift.git
cd demo-gift
mvn clean package
java -jar target/demo-1.0-SNAPSHOT.jar --redis.ip=localhost --redis.port=6379 --gift.count=10000

##4. load test # mock DDos - This runs a benchmark for 10 seconds, using 4 threads, and keeping 500 HTTP connections open.
wrk -t4 -c500 -d10s http://localhost:8080/gift/

# the normal case - one use can only get gift once
wrk -t4 -c100 -d2s http://localhost:8080/gift/1

About

This is a project for demonstrating the second-killing activity typically used by e-commerce shop promotion.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published