当前位置:网站首页>高并发介绍及应对
高并发介绍及应对
2022-07-02 22:07:00 【西木Qi】
高并发
一、高并发的介绍
我们所说的高并发指两方面,第一个方面指的是同一时刻有大量的请求访问系统 第二个方面指的是有大量的请求在一个时间段内访问系统,一般时间段有个指标,是一秒内能处理的请求数量。
二、高并发的处理
2.1、提升单台服务器性能
例如加内存,CPU核数等等。
2.2、部署多台机器分担压力
使用负载均衡的帮助,同时需要程序支持负载均衡方式的部署,比如引入Redis来统一存储Session;
2.3、如果单机单机能承载的能力有限,远远达不到上限,则需要查找性能瓶颈:
2.3.1 数据库
采用读写分离、分库分表、多主、多从架构提升数据库处理能力;
2.3.2 引入缓存机制
将数据存储在内存当中,即引入缓存机制,先查缓存,缓存中不存在则查询数据库,然后再存储到缓存中。【缓存一致性问题:可通过订阅binlog日志,或者MQ方式保证数据最终一致性】
2.3.3 引入Redis集群
Redis虽然单机性能很高,但为了支持高并发,一般需要部署成集群方式。
三、数据处理能力问题的解决办法
一个业务假设最大处理能力也就一秒一万,但是有一秒百万的请求过来该怎么办?
3.1 使用MQ
先把请求放到MQ,排着队来出口处根据处理能力来消费,这种方式可能需要用户等待一会儿处理结果,比如:支付场景、抢购场景、秒杀场景等。
3.2 限流
如果系统处理能力有限,只能做到承载一秒一万的流量,但是有百万的请求怎么办,这时也可以限流,让流量分批次的进入系统处理。
3.3 DNS负载均衡
如果请求入口流量过大,则可以使用DNS负载均衡,将同一个域名访问分发到不同节点来处理。
3.4 CDN
将静态资源放到CDN中加快访问;
3.5 搜索使用ES;
3.6 拆分成微服务
将系统进行拆分,改成微服务,将每一个模块独立部署成集群,即每一个模块都是集群。
3.7 其他
代码方面,使用多线程提高处理能力,使用连接池方式降低数据库连接、远程调用等的开销。
边栏推荐
- 附加:【登录信息存储】与【登录状态校验】;(包括:总结了到目前为止,有关【登录信息存储】与【登录状态校验】的所有内容;)
- Hanoi Tower problem
- 影视随摘
- [shutter] shutter application life cycle (foreground state resumed | background state paused | inactive | component separation state detached)
- U++ learning notes - relaxation
- 杰理之直接触摸样机的顶针反应不正常【篇】
- SimpleITK使用——4. 奇怪的問題
- Meibeer company is called "Manhattan Project", and its product name is related to the atomic bomb, which has caused dissatisfaction among Japanese netizens
- Tencent three sides: in the process of writing files, the process crashes, and will the file data be lost?
- Market Research - current situation and future development trend of marine clutch Market
猜你喜欢
建立自己的网站(22)
[LeetCode] 数组中的第K个最大元素【215】
It's not easy to say I love you | use the minimum web API to upload files (swagger support) # yyds dry inventory #
NC24325 [USACO 2012 Mar S]Flowerpot
[error record] the flutter reports an error (could not read script 'xxx\flutter\u tools\gradle\app\u plugin\u loader.gradle')
wait解决僵尸进程
#include errors detected. Please update your includePath.
UE4 游戏架构 学习笔记
Oracle PL / SQL programming
"Actbert" Baidu & Sydney University of technology proposed actbert to learn the global and local video text representation, which is effective in five video text tasks!
随机推荐
Market Research - current situation and future development trend of anti-counterfeiting label market
Mathematical modeling -- graph and network models and methods (I)
杰理之内置短按再长按,不管长按多长时间都是短按【篇】
[shutter] shutter gesture interaction (small ball following the movement of fingers)
U++ 学习笔记 ----松弛
Scrcpy this software solves the problem of sharing mobile screen with colleagues | community essay solicitation
It's not easy to say I love you | use the minimum web API to upload files (swagger support) # yyds dry inventory #
New feature of go1.18: trylock, which has been tossed n times
影视随摘
Get off work on time! Episode 6 of Excel Collection - how to split and count document amounts
Struct, bit segment, enumeration, union
Attack and defense world PWN question: Echo
附加:【登录信息存储】与【登录状态校验】;(包括:总结了到目前为止,有关【登录信息存储】与【登录状态校验】的所有内容;)
Market Research - current market situation and future development trend of marine wet exhaust hose
对象与对象变量
phpcms实现订单直接支付宝支付功能
Perceptron model and Application
图形视图框架
Market Research - current market situation and future development trend of night vision goggles for pilots
U++ 原始内存 学习笔记