On October 20, the annual Double Eleven kicked off. Li Jiaqi started broadcasting on time at 2:30 in the afternoon. The continuous live broadcast lasted 12 hours and 26 minutes. A total of 439 products were on the shelves, and the total transaction volume in the live broadcast room was as high as 11.5 billion yuan. , The estimated sales volume is 37.71 million. This transaction volume is close to hundreds of small-scale companies’ annual revenue. It can be seen that live e-commerce has been extremely popular in recent years, from small grass-growing bloggers to traffic stars, from Li Jiaqi, Wei Ya to Luo Yonghao, and many cities that have become rich overnight. The legend guides a massive influx of players, and all imaginable traffic with high and low levels of realisation is swarming.
As a technical practitioner of e-commerce business, high sales means high guarantee, and higher requirements for the ability of back-end engineers. Millions of users rushed into the live broadcast room, snapped up merchandise, and traffic surged. How to ensure the high availability of the system? How should the spike system be designed? What are the core challenges facing?
Technical difficulties
The spike system has: time-limited, limited, fixed-point, manual shelves, instantaneous traffic peaks, short duration and other business characteristics. Its technical characteristics are: high instantaneous concurrent flow, more reading and less writing, and simple process. Based on the above characteristics, the spike system is in Generally, the following principles should be followed when designing:
- Asynchronous decoupling
- Limit flow and block requests upstream as much as possible
- Make the most of the cache
Of course, in addition to the principles that should be followed, the following issues have to be considered during the design of the spike system:
1, oversold
When the payment order quantity is greater than the current product inventory, there will be an oversold problem. For example, there are only 300 products in the inventory, but 350 units are sold in a flash sale. The oversold problem will first cause the merchant to have no goods to send, which is easy It causes complaints from merchants and users, and may cause compensation. If the coupons are oversold, it will directly cause asset loss. Therefore, the oversold problem is the primary solution when designing the spike system.
2. High concurrency
Based on the characteristics of the above spike system: short time and instantaneous traffic peaks, spikes often last only a few minutes. In high concurrency scenarios, the user's request can be simply summarized as: get cache-query data-rebuild cache-return result, if it hits the cache The result is returned directly, but a large number of concurrent requests in a short period of time may cause cache breakdown or invalidation. How to solve these problems has to be considered.
Solution
Taking the usual trading platform architecture design as an example, we need to pay attention to the establishment of trading services, scenarios, and basic capabilities. We divide the spike architecture, roughly divided into four layers: user layer, load balancing layer, application layer and persistence layer
Oversold Solution
The basic idea to solve the oversold problem is:
- Directly rely on the DB transaction mechanism to strengthen consistency and oversold verification;
- Ensure sufficient performance; (Ensure that the service capabilities of the DB are provided to the writing scene as much as possible)
- Handle exceptions reasonably;
- Deal with oversold in real time; close orders over time + increase overtime time for deducting inventory; real-time monitoring + real-time intervention
- Try not to use asynchronous deduction of inventory
Solution: Synchronization, order to reduce inventory, code epitome:
Deduction of inventory:
UPDATE t_seckill_goods SET count = count -1, version = version +1 WHERE id = ? AND count > 0 AND version = ?
Roll back inventory:
UPDATE t_seckill_goods SET count = count +1, version = version +1 WHERE id = ? version = ?
Of course, solving the above problems is not only a synchronous method of placing orders and reducing inventory, but also asynchronous. Returning to the spike system itself, the technical layer only solves the functional problem. For the spike in the live broadcast room, its essence is still marketing, and the essence of marketing is that attraction is not forced~
Ding Dong! Welfare time
The above-mentioned spike system solution is only the tip of the iceberg among Tencent Classroom’s massive high-quality IT Internet courses, as well as programming languages, front-end development, software development (testing), certification exams, cloud computing big data, network and operation and maintenance, game development, More high-quality courses and content in hardware R&D and other fields. In addition, 1024 Programmer's Day, Tencent Classroom also launched an exclusive event, it can be described as full of ritual!
As a holiday for programmers, 1024 is no longer a simple day on the calendar. It carries the programmer's unique melancholy and romance. Wandering in the world of 0 and 1, this romance is concealed by every busy day, but even so, in 1024 this special day, we should be different, right?
Are there roses in someone else's 520 Valentine's Day? But in the world of programmers (522 in hexadecimal is equal to 1314 in decimal), 1314 blessings will be sent at 522.
Do others post couplets during the Spring Festival? But in the world of programmers, they will use a piece of code to write "Hello World" as a message to themselves in the new year...
So, #1024programmers festival#, what will Tencent Classroom bring to fill this exclusive holiday ceremony?
Add BUFF to the wave of tyrants and reap your holiday blessings and vision!
【Activity Prizes】
1. 1617373b8648d6 five-character set card ("BUG Duck Elimination" Symbol, " , "Never Dying Chicken" Symbol, "Become a Big Bull" Symbol, and "Find Object" Fu) friends can get a limited edition Ba Fu T-shirt, the quantity is limited, first come first served.
2. Egg Award will receive the Bafu digital collection issued by Tencent Classroom for the first time. Each Bafu digital collection is limited to 500 copies, totaling 2500 copies.
【Regulations】
1. The user logs in to H5, shakes it to interact, shakes out different tyrants, and collects five types to redeem the basic prizes; shakes out the tyrants to get the NFT digital collection.
2. Each user has 5 chances to "Shake the Lord Talisman". After the number of times is exhausted, they can unlock additional chances by participating in the fun quiz, up to 50 times.
3. The user enters the community station, locks the activity link, and clicks to win the gift (gifts include cash red envelopes, course discounts, NFT master symbols, 3C top goods, digital physical prizes, professional knowledge, cash red envelopes, customized T Shirts, etc.)
What are you waiting for? Come and participate now, more surprises are waiting for you to unlock!
Scan QR code
Get your 1024 exclusive " " 1617373b8649b6~
Click [here] Get your 1024 exclusive "Talisman"
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。