An ecommerce platform as web application project.
| Frontend | jQuery, Thymeleaf, Bootstrap |
| Backend | SpringBoot, MyBatis |
| Middleware | Redis, RabbitMQ |
| Database | MySQL |
To support distribution, single session is no enough:
With Nginx's load balancing, requests are distributed to different Tomcats according to time order.
Suppose a user signs in at Tomcat1, the information will be stored in Session on Tomcat1. Later another request from the same user is distributed to Tomcat2, where no info of this user has been stored in Session, then the user will have to sign in again, which produces a bad experience.
- Why Redis: security and easy scaling out.
-
Exception Handler:
- SpringMVC allows entralized handle of Exceptions. In this project, I used @ControllerAdvice and @ExceptionHandler annotations to catch different types of exceptions and prompt messages.
-
Password Encryption: Double-layer salted hash
- Frontend encryption: to avoid password being sent as clear text.
- Backend encryption: hash password again before storing into database, in case of data leakage during transmission.
-
Password Update:
- Similar roadmap as Login/Register, with UserController and UserService.
- Delete cache in Redis after update password in database to ensure cache consistency.
-
Listing:
- Iterative blocks with Thymeleaf for list of products.
-
Deal Period Validation:
- Backend: Initialize deal status and countdown variable based on current server's time when fetching sales data from database.
- Frontend: Conditional function based on deal status and countdown function with timeout.
- Check on server:
- Keep track of stock status flags (empty/not) on server to reduce communication with Redis; if status is empty, skip following steps.
- Check and update on Redis:
- Pre-decrement stock on Redis to check if stock is enough; if not, add it back, update status on server, and skip following steps.
- Update on database:
- Send message to queue and wait for processing, where OrderService will update product stock in database when creating new order.
- Caching pages and objects.
- Minimize #requests to Redis and database.
- Implement a message queue to improved spike handling through asynchronous communication.
Prepared 1500 users and user tickets (see implementation in UserUtil) for purchasing load test.
- As shown above, there has been significant increase in throughput and decrease in response time.
- With message queue implemented, the system perfectly managed data spikes (marked as yellow) and maintained steady processing (marked as green) without crashing the database, ensuring that the data is persisted and handled.
(In progress)









