当前位置:网站首页>高并发介绍及应对
高并发介绍及应对
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 其他
代码方面,使用多线程提高处理能力,使用连接池方式降低数据库连接、远程调用等的开销。
边栏推荐
- Socket socket c/s end process
- [shutter] shutter gesture interaction (small ball following the movement of fingers)
- Market Research - current situation and future development trend of preclinical medical device testing service market
- Mathematical modeling -- graph and network models and methods (I)
- An overview of the development of affective computing and understanding research
- [QT] Q multithreaded development - Analysis of multithreaded application examples (Mandelbrot)
- [shutter] shutter application theme (themedata | dynamic modification theme)
- Oracle cursor
- 杰理之内置关机电流 1.2uA,之后不能长按开机【篇】
- [shutter] shutter page life cycle (initialization period | createstate | initstate | update period | build | destroy period | dispose)
猜你喜欢

Source code analysis - lightweight asynchronous crawler framework Ruia

540. Single element in ordered array

Share how to make professional hand drawn electronic maps

Utilisation de simpletk - 4. Question étrange
![[ODX studio edit PDX] -0.1- how to quickly view the differences in supported diagnostic information between variant variants (service, sub function...)](/img/2b/f31b81cedf37ca187bcaa20dfe0b83.png)
[ODX studio edit PDX] -0.1- how to quickly view the differences in supported diagnostic information between variant variants (service, sub function...)
![Additional: [login information storage] and [login status verification]; (including: summarizing all the contents of [login information storage] and [login status verification] so far;)](/img/b7/0f543829b57cf2f2544efec4910c17.png)
Additional: [login information storage] and [login status verification]; (including: summarizing all the contents of [login information storage] and [login status verification] so far;)

Niuke: Dragon and dungeon games

Micro service gateway selection, please accept my knees!
![[LeetCode] 数组中的第K个最大元素【215】](/img/72/d3e46a820796a48b458cd2d0a18f8f.png)
[LeetCode] 数组中的第K个最大元素【215】

【外刊】睡眠与减肥
随机推荐
Socket套接字C/S端流程
Objects and object variables
Commodity information management system (C language document version)
《乔布斯传》英文原著重点词汇笔记(十一)【 chapter nine】
杰理之样机在多次触摸后会触发关机【篇】
Market Research - current situation and future development trend of cell-based seafood market
Market Research - current situation and future development trend of marine clutch Market
【AUTOSAR-DCM】-4.3-UDS $22和$2E服务如何读取和写入NVM数据
Introduction to database system Chapter 1 short answer questions - how was the final exam?
Task and privilege level protection
杰理之样机无触摸,拆机之后重新安装变正常【篇】
[micro service sentinel] rewrite Sentinel's interface blockexceptionhandler
PHP微信抢红包的算法
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
Market Research - current market situation and future development trend of third-party data platform
Market Research - current market situation and future development trend of genome editing mutation detection kit
Share how to make professional hand drawn electronic maps
Market Research - current market situation and future development trend of handheld wound imaging equipment
杰理之充电拔出,无法触摸开机【篇】
Graphic view frame