当前位置:网站首页>大白话高并发(二)
大白话高并发(二)
2022-07-06 20:21:00 【你大晨哥】
背景
这是三高专题的第二篇,我想了很久应该怎么去串联这个专题,后来我觉得就按照流量的方向来聊吧,从用户请求到服务端再到用户。
突然间来了200万个请求
我们一台服务器能承受住200万个请求么?答,可以,但是有条件只能是三次握手后的空链接,我们知道linux中一切皆文件,因此一个请求对一个linux来说也是一个文件fd,那只要我的linux文件数量足够大就可以接收200万个请求,一个请求默认为4k,200w * 4k 不过8M左右的内存是没有问题的,但是前提这些都是空链接,如果客户端发送了大量的数据到服务端,服务端又需要通过做cpu做大量的计算,处理后又将大量的数据返回给客户端,那样别说2000万,1000都是费劲的。
对于我们秒杀这种场景来说,单台机器不可能承受200万个请求,因此需要引入负载均衡。将请求路由到多个地方。
NGINX
首先我想到了nginx,nginx是7层的负载均衡,并发量大概在5w左右,如果想支撑200万并发,需要有40个nginx才行。
LVS 或者 F5服务器
一台nginx 5万并发,因此需要在nginx上面再来一层4层负载均衡,都说lvs并发在几十万,假设为20万,需要10台lvs。
DNS负载均衡
一台lvs看样子还是不能承受200万并发,看来在他的上面还需要一层,这一层就是DNS,通过ip来做负载均衡,一个lvs一个ip。
总结
上亿的并发也是这个套路,一层不够就再加一层,ip不够就再加几个ip,机房不够就再加几个机房。
参考
边栏推荐
- Jerry's question about DAC output power [chapter]
- opencv环境的搭建,并打开一个本地PC摄像头。
- 树莓派设置静态ip
- Cocos2d-x Box2D物理引擎编译设置
- CVPR 2022 best paper candidate | pip: six inertial sensors realize whole body dynamic capture and force estimation
- 从0开始创建小程序
- Stored procedures and functions (MySQL)
- Jericho turns on the display icon of the classic Bluetooth hid mobile phone to set the keyboard [chapter]
- Jerry's broadcast has built-in flash prompt tone to control playback pause [chapter]
- DOMContentLoaded和window.onload
猜你喜欢

25.(arcgis api for js篇)arcgis api for js线修改线编辑(SketchViewModel)

Shangsilicon Valley JVM Chapter 1 class loading subsystem

2022.6.28

Do you know the five most prominent advantages of E-bidding?

Not All Points Are Equal Learning Highly Efficient Point-based Detectors for 3D LiDAR Point

Flutter3.0, the applet is not only run across mobile applications

“去虚向实”大潮下,百度智能云向实而生

体会设计细节

Function reentry, function overloading and function rewriting are understood by yourself

华为小米互“抄作业”
随机推荐
房费制——登录优化
应用程序启动速度的优化
杰理之在非蓝牙模式下,手机连接蓝牙不要跳回蓝牙模式处理方法【篇】
LAB1配置脚本
Basic concepts of Huffman tree
unrecognized selector sent to instance 0x10b34e810
Principle of attention mechanism
Flink Task退出流程与Failover机制
Stored procedures and functions (MySQL)
函数重入、函数重载、函数重写自己理解
Open3D 网格滤波
Do you know the five most prominent advantages of E-bidding?
图形化工具打包YOLOv5,生成可执行文件EXE
从0开始创建小程序
U.S. Air Force Research Laboratory, "exploring the vulnerability and robustness of deep learning systems", the latest 85 page technical report in 2022
HDU ACM 4578 Transformation-> Segment tree - interval change
The first symposium on "quantum computing + application of financial technology" was successfully held in Beijing
Lab1 configuration script
线性表的查找
迷失在MySQL的锁世界