当前位置:网站首页>How to design a seckill system?
How to design a seckill system?
2022-06-23 17:32:00 【User 7353950】
Seckill system mainly has three characteristics High performance 、 High concurrency 、 High availability .
Starting from the process of a second kill , Consider the three characteristics of seckill system , Then you can design a seckill system .
1. Seckill page access
Optimization plan :
- Dynamic and static separation . Deploy the static resources of the page to Nginx perhaps CDN, This can speed up the seckill page acquisition .
- Static resource merge acquisition . By merging multiple requests into a single request , Get multiple static resources at a time , This can speed up the seckill page acquisition .
- service degradation . The seckill page is degraded , List the recommended products 、 Downgrade comments, etc , Show less or no . You need to log in to view the seckill page , Return to the login interface directly for users who are not logged in .
- Service monitoring . Monitor the flow , Use the token bucket algorithm and other flow limiting algorithms to control the flow . Fuse some tasks if necessary .
- Page data cache . Cache page data to Redis in , Reduce database operations .
- Second kill connection adding salt . send URL Dynamic , Illegal user operations can be reduced .
2. Order goods
Optimization plan :
- front end / Back end current limiting . front end / Client anti shake . Limit the number of orders placed within the time interval .
- Anti robot brushing . Add the step of filling in the verification code for the order placing operation , Such as :55+44=?、“ Hello ” Lowercase Pinyin of 、 Select all the aircraft and other questions , Filter out illegal requests .
- Withholding inventory when placing an order . When designing database tables, you need to set the lock inventory field . During the second kill , Inventory reduction will be Redis Using distributed locks in . Other subsequent operations can use RabbitMQ To operate .
- Withholding inventory when placing an order ( Stock preheating ) You can add delay queues . Forward the timeout goods to the dead letter route , And then operate .
- Asynchronous operation can be performed when placing an order , Multiple threads can be used for operations such as double price verification .
3. payment
Optimization plan :
- Divide payments into a separate system , Only the corresponding payment interface is opened . Because the payment system is financial sensitive , Therefore, the high availability of the payment system should be guaranteed .
- Rollback mechanism . Distributed transactions are recommended , For the payment business TCC Business , Because the payment system is financial sensitive .
therefore , Seckill system usually introduces MQ、Redis、MySQL、Nginx Such as middleware , Each middleware needs to be High performance 、 High concurrency 、 High availability Analysis of .
MQ
Optimization plan :
- Cluster deployment .MQ Systems are generally deployed in clusters , Deploy the image cluster , Can improve the availability of the system .
- Turn on persistence . Yes MQ The information in the system turns on persistence , Brush it into the hard disk , Prevent downtime .
- Turn off automatic consumption ACK, Manual operation is required ACK. Prevent abnormal information consumption .
Redis
Optimization plan :
- Redis Read and write separation ,Master Node to write , Read from other nodes .
- Redis Deploy sentinels , After a node goes down, it can be replaced by a machine .
- Redis Deploy the partitioned cluster , Distribute the requests to each server Redis On the machine .
- Enable persistent logging .AOF and RDB Adjust according to business conditions .
- A system can have multiple Redis colony , For example, page data and product order Redis You can use multiple clusters Redis.
MySQL
Optimization plan :
- Index based on business . unique index 、 General index 、 Joint index, etc .
- See if the business is optimized , Reduce the return operation .
- Sub database and sub table .MySQL Cluster deployment should be done , A single Redis Usually only 2000QPS about .
- sub-treasury . Use MyCat perhaps ShardingSphere And so on , Assign the operation to the corresponding machine by algorithm .
- table . There are two types of sub tables: vertical and horizontal . Vertical partitioning is to divide some fields into other tables . Horizontal partitioning is to divide data horizontally into different tables in the same database , Avoid too large data on a table .
- Generally speaking , Suggestion points 32 Databases , Each Treasury point 32 A watch , This can fully meet the needs of most enterprises .
- MySQL The bottleneck is disk IO, Solid state drives can be replaced .
Nginx
Optimization plan :
- Dynamic and static separation . Deploy static resources to Nginx in , No need to query in other middleware .
- Nginx The current limiting operation can be started . Both token bucket and exposed copper algorithm support .
- Nginx Turn on load balancing , Send the service request to different servers , Reduce the pressure on a single server .
Except for the ones listed above , There are many optimization operations .
Hot data separation
The systems used by hot goods and ordinary goods can be isolated , In this way, even if the secsha system goes down , There won't be any problem in ordering ordinary goods .
- Second kill products are put into the hot data system .
- Live broadcast products can also be put into the hot data system .
- Traffic monitoring . Products with more orders can be put into the hot data system .
- Merchant Report . Businesses can report commodities that may sell more in the future , Put it in the hot data system .
- Data analysis . Analyze past data , Some products that may sell more in the future , Put it in the hot data system .
performance optimization
Finally, you can optimize the performance of the machine .
- Replace CPU
- Replace memory
- Replace a faster hard drive
- to update Linux system kernel
- Update the stable version of the software system
- close Linux Some useless services above
Seckill system mainly has three characteristics High performance 、 High concurrency 、 High availability . Just think about these three points , Then we will gradually come up with a second kill system .
边栏推荐
- What are the inductance parameters? How to choose inductance?
- Interface ownership dispute
- ABP framework - data access infrastructure (Part 2)
- Meituan Sanmian: how do you understand the principle of redis master-slave replication?
- 《MPLS和VP体系结构》
- Another breakthrough! Alibaba cloud enters the Gartner cloud AI developer service Challenger quadrant
- Redis cluster operation method
- How can the points mall make profits
- 一文入门智能开关的3种功能形态
- Hands on data analysis unit 2 section 4 data visualization
猜你喜欢

千呼万唤,5G双卡双通到底有多重要?

ctfshow php的特性

Ctfshow PHP features

qYKVEtqdDg

Shushulang passed the listing hearing: the gross profit margin of the tablet business fell, and the profit in 2021 fell by 11% year-on-year

DataNode进入Stale状态问题排查

Jetpack Compose 与 Material You 常见问题解答

The official Chinese course of zero foundation introduction jetpack compose is coming

QT布局管理器【QVBoxLayout,QHBoxLayout,QGridLayout】

The Google play academy team PK competition is in full swing!
随机推荐
【网络通信 -- WebRTC】WebRTC 源码分析 -- 接收端带宽估计
JS common error reporting and exception capture
qYKVEtqdDg
How to select securities companies? Is it safe to open a mobile account?
开户券商怎么选择?现在网上开户安全么?
Wechat applet: time selector for the estimated arrival date of the hotel
How to select an oscilloscope? These 10 points must be considered!
以 27K 成功入职字节跳动,这份《 软件测试面试笔记》让我受益终身
EasyPlayer移动端播放webrtc协议时长按播放页面无法关闭“关于我们”页面
Tupu digital twin 3D wind farm, offshore wind power of smart wind power
查数据库中每张表的大小
解答01:Smith圆为什么能“上感下容 左串右并”?
Look, this is the principle analysis of modulation and demodulation! Simulation documents attached
Why do we say that the data service API is the standard configuration of the data midrange?
How about stock online account opening and account opening process? Is online account opening safe?
官方零基础入门 Jetpack Compose 的中文课程来啦
[untitled] Application of laser welding in medical treatment
MySQL事务及其特性与锁机制
[network communication -- webrtc] analysis of webrtc source code -- supplement of pacingcontroller related knowledge points
Here comes the official zero foundation introduction jetpack compose Chinese course!