/shopping-system

A maven web project that mimics the online shopping process. Supports Register, Log in, Log out, Add items to cart, and checkout.

Primary LanguageJava

Shopping-system

A maven web project that mimics the online shopping process. Supports Register, Log in, Log out, Add items to cart, and checkout.

Branches

  • master: Classic Spring MVC + WebFlow + Security
  • boot: SpringBoot + MVC + WebFlow + Security
  • redis: Using redis+rabbitmq to deal with high-concurrency
  • multithreading: Using parallel threading to increase performance

Usage:

mvn spring-boot:run

Project Architecture for Registration Process

readme image

Project Architecture for High Concurrent Request for Products

readme image

High Concurrent Product Requests Scenario

  • When the process time is much greater than the average request interval, if we use normal way of RPC inconsistencies may occur such as over-selling.

  • Preload the mysql product information to Redis: Reduce the number of times the product is queried from mysql.

  • Use RabbitMQ to deal with high rate of requests: Requests are processed in the order they arrived at the message queues.

  • To see an example, run HighConcurrencyTest in CartItemHighConcurrencyControllerTest.java. In this scenario, we have three customers sending requests at an average rate of 235 milliseconds, with total of 50 requests competing for 30 products, and the process time for a request is 1007 milliseconds (Just let the thread to sleep, actually could be much faster.

  • The log file generated from this test is here .

  • We can see that the results are synchronous with the database results as follow:

(1) The cart Item Table readme image

(2) The Customer Table readme image

  • Also, the message queue rates are as follow:

readme image