How to design a spike system

How to design a spike system

Overview

The characteristic of the spike system is that the instantaneous flow is large, the products are always limited first come first served, and there is a clear start and end time.

Program

For the spike, you must first set the spike inventory, spike price, and spike start time and time in the background. Stores that need to participate in the spike will start the spike when the time comes. There will be bursts of traffic during the spike. If the system is not set properly, It will be paralyzed, and current limiting will generally be implemented, such as access-side current-limiting, server-side current-limiting, and the use of buffers and message queues to increase processing speed; one of the most difficult problems is the deduction of inventory to prevent oversold and prevent oversold There are many ways to sell. For conventional spikes, you can update the inventory with the pessimistic lock of the database. For the slightly higher concurrency, you can use distributed locks to prevent oversell. For the particularly high concurrency, you can use the atomic operation of the redis cache. , In short, choose different implementation schemes for specific services. Don't use high concurrency for the sake of high concurrency. Find a balance point based on the business of the system and choose the method that suits you.

to sum up

The architecture needs an evolutionary thinking. Don’t pursue high concurrency as soon as you come up. Instead, you should design the architecture according to the business situation and user usage. Don’t do things that need to be designed in advance. Such over-design will cause the product to be too complicated. , It is difficult to expand, it is not worth the loss. It is the most reasonable approach to have a modest architecture and keep evolving at all times.
Welcome to follow the technical public account:
How to design a spike system

Guess you like

Origin blog.51cto.com/xxdeelon/2532776