当前位置:网站首页>Interviewer: how to deal with high concurrency?
Interviewer: how to deal with high concurrency?
2022-07-26 12:28:00 【User 9919783】
I chatted with my high school classmates yesterday , Large factories need high concurrency experience and cannot enter , Only enter small workshops , There is no need to deal with high concurrency in small workshops , Such an endless cycle . High concurrency experience , It will never be out of date in the interview scene , It plays an important role , Spike scenario traffic peak shaving is one of the high concurrency .
What is high concurrency ?
High and pointed at the same time , A large number of customer requests , Access server ,update Modify database data , Now update Lock the watch , Wait for execution to complete before processing the next request , When customer requests accumulate to a certain amount , Database link limit exceeded , Will return link timeout , Also because of too many requests , Add the same data twice , There is no guarantee of data consistency . The core element of high concurrent requests is to ensure that a large number of requests are highly available , Uniformity , High performance . As can be seen from the above , Ensure the stability of the system , It can reduce the direct impact on DB Request update of layer data .
How to ensure high performance ?
The customer layer can adopt the methods of user answering questions and entering verification code , Limit the number of requests , prevent 0 Click the moment of seconds , The peaks are all concentrated , The most important thing is to prevent someone from cheating and killing , And it can also delay customer requests , Bar requests are distributed in different time periods .
The business layer can limit the number of interface calls .
Flow peak shaving can also be used to achieve , Nowadays, there are a large number of excellent open source frameworks supporting traffic peak shaving , Such as RabbitMq and kafka etc. .RabbitMq In addition to the functions of decoupling and asynchrony , It can also realize flow peak shaving , Store a large number of user requests in mq In line , Then you can allocate and enter the database in other time periods .
How to ensure consistency ?
When consuming warehouse inventory , Before each consumption , Judge once count>0, When there is inventory , Can we continue to consume and execute , Otherwise, roll back .
How to achieve high availability ?
Last , In order to ensure the high availability of the server , It must be deployed on multiple servers to ensure that one of them is down , The system is still working .
service degradation
When the request reaches the system capacity , You can turn off other non core functions first , Try to give all the system memory to the seckill function , Ensure the normal operation of secsha .
Service restriction
Flow restriction refers to the flow restriction of the access request of the interface , It can also be used. rabbitmq Carry out current limiting ,mq The queue flow will be limited , Once the expiration time is exceeded , Will be discarded , The client failed quickly and tried again in the second round .
Refuse request
When service degradation and service flow restriction cannot be solved , Finally, only one error page can be returned to the user , such as “ Too many user requests ”“ Service is busy , Try again later ” etc. , It only happens when the server is overloaded , There will only be temporary unavailability , Once the normal server load drops , You can normally request .
边栏推荐
- Introduction to FPGA (III) - 38 decoder
- 2、 Container_
- 14.2字节流学习
- El form displays two columns per row, with the bottom button centered
- 羽毛球馆的两个基础设施你了解多少?
- Introduction to FPGA (II) - one out of two selector
- 若有声明”int x=5,y=1;”,则表达式x<y?x++:y++的结果是:
- 基于STM32的SIM900A发送中文和英文短信
- Redis主从复制原理
- .eslintrc.js configuration description
猜你喜欢

Network protocol: tcp/ip protocol

Dry goods semantic web, Web3.0, Web3, metauniverse, these concepts are still confused? (medium)

Jsj-3/ac220v time relay

Introduction to FPGA (II) - one out of two selector

VS code 设置Ctrl+S保存,自动格式化的方法

回溯——46. 全排列

Flink's real-time data analysis practice in iFLYTEK AI marketing business

动静态库的实现(打包动静态库供他人使用)

干货|语义网、Web3.0、Web3、元宇宙这些概念还傻傻分不清楚?(中)

Overseas app push (Part 2): Channel Integration Guide for overseas manufacturers
随机推荐
2022.7.23 ------ leetcode. Jianzhi offer.115
.NET WebAPI 使用 GroupName 对 Controller 分组呈现 Swagger UI
The.Net webapi uses groupname to group controllers to render the swagger UI
自定义浏览器默认右击菜单栏
Map函数统计字符出现的次数
回溯——46. 全排列
Emerging security providers to learn about in 2022
Pytoch deep learning quick start tutorial -- mound tutorial notes (I)
Redis主从复制原理
uniapp h5、app引用外部在线js
Why BGP server is used in sunflower remote control? Automatic optimal route and high-speed transmission across operators
Use and optimization of MySQL composite index (multi column index)
How do children's playgrounds operate?
Microsoft has shut down two attack methods: Office macro and RDP brute force cracking
The significance of Internet of things device encryption
Here blog: running a large language model in a production environment - overview of the reasoning framework
【微信小程序】一文读懂,数据请求
Pytoch deep learning quick start tutorial -- mound tutorial notes (II)
Introduction to FPGA (II) - one out of two selector
编程式导航路由跳转到当前路由(参数不变), 多次执行会抛出NavigationDuplicated的警告错误?