当前位置:网站首页>高并发介绍及应对
高并发介绍及应对
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 其他
代码方面,使用多线程提高处理能力,使用连接池方式降低数据库连接、远程调用等的开销。
边栏推荐
- 杰理之样机无触摸,拆机之后重新安装变正常【篇】
- 大话云原生之负载均衡篇-小饭馆客流量变大了
- 建立自己的网站(22)
- Source code analysis - lightweight asynchronous crawler framework Ruia
- U++ 原始内存 学习笔记
- Developers share | HLS and skillfully use Axi_ Customize the master bus interface instructions and improve the data bandwidth - area exchange speed
- Market Research - current market situation and future development trend of intravenous injection (IV) bottles
- Market Research - current situation and future development trend of carob chocolate market
- New feature of go1.18: introduce new netip Network Library
- Perceptron model and Application
猜你喜欢
Oracle cursor
Oracle-游标
Utilisation de simpletk - 4. Question étrange
NC24325 [USACO 2012 Mar S]Flowerpot
Additional: [login information storage] and [login status verification]; (including: summarizing all the contents of [login information storage] and [login status verification] so far;)
Tencent three sides: in the process of writing files, the process crashes, and will the file data be lost?
Graphic view frame
基于ASP.net的手机销售管理系统(二手手机销售管理系统)+ASP.NET+C#语言+VS2010+数据库可以用于课设、毕设学习
Based on asp Net (used mobile phone sales management system) +asp Net+c # language +vs2010+ database can be used for course design and post design learning
对象与对象变量
随机推荐
NC24325 [USACO 2012 Mar S]Flowerpot
#include errors detected. Please update your includePath.
Share how to make professional hand drawn electronic maps
Mathematical modeling -- graph and network models and methods (I)
基于ASP.net的手机销售管理系统(二手手机销售管理系统)+ASP.NET+C#语言+VS2010+数据库可以用于课设、毕设学习
Simpleitk use - 4 Strange question
Market Research - current market situation and future development trend of night vision goggles for pilots
原生js添加样式的方法
《乔布斯传》英文原著重点词汇笔记(十一)【 chapter nine】
`${}`的用法
[QT] Q multithreaded development - Analysis of multithreaded application examples (Mandelbrot)
php实现根据输入的年龄查询出生日期符合的数据
Oracle PL / SQL programming
Based on asp Net (used mobile phone sales management system) +asp Net+c # language +vs2010+ database can be used for course design and post design learning
Web side defense Guide
Baidu AI Cloud - create a face recognition application
Regular expression (2)
Learn computer knowledge from scratch
U++ 原始内存 学习笔记
"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!