Analysis on e-commerce flash sales and flash sales
Flash sales and flash sales of e-businesses are not a stranger to us. However, from a technical point of view, this is a huge test for Web systems. When a Web system receives tens of thousands or more requests within one second, system optimization and stability are crucial. This time, we will focus on the technical implementation and optimization of flash sales and flash sales.
Large e-commerce flash sales, there must be a lot of awesome technologies, balance of liabilities, and north-south images... Wait. I just want to write a solution for my flash sales business!
First go to the flowchart:
What should I do with the concurrency of a flash sales activity on an e-commerce website? Message Queue
AMQP (Advanced Message Queuing Protocol) is an open standard for application layer protocols and is designed for Message-oriented middleware. Message-oriented middleware is mainly used for decoupling between components. message senders do not need to know the existence of message users, and vice versa.
AMQP features message-oriented, queue-oriented, routing (including point-to-point and publish/subscribe), reliability, and security.
RabbitMQ is an open-source AMQP implementation. The server side is written in Erlang and supports multiple clients, such as Python, Ruby, and ,. NET, Java, JMS, C, PHP, ActionScript, XMPP, STOMP, etc. AJAX is supported. It is used to store and forward messages in a distributed system, and has good performance in terms of ease of use, scalability, and high availability. I have some friends who are playing RabbitMq!
The user request will post some background information such as (user information, product information) to the message queue.
Message Queues use the Windows service to process parsed information and process it in a single thread (multithreading may cause problems, you know )!
If it is successful, it will be inserted into the success record table of this activity; if it fails, it will be inserted into the intentionally purchased table (to facilitate sales by business personnel )!
How to notify users?
1. ajax asynchronous request (request a successful record every two minutes. If the database is not requested, we will use Redis cache)
2. persistent connection (websocket, signalr, etc)
In short, I want to do a good job in flash sales and other businesses, and the road is long enough. I hope you can provide more guidance!