-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
35e39f7
commit fd4a288
Showing
3 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## 目录 | ||
|
||
1. [1负载均衡](./1负载均衡.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
## 负载均衡 | ||
|
||
[推荐](https://www.cnblogs.com/itfly8/p/5043435.html) | ||
|
||
[参考](http://lobert.iteye.com/blog/2159970) | ||
|
||
根据服务器的能力(硬件),承担相应的工作,是解决高性能,单点故障(高可用),扩展性(水平伸缩)的终极解决方案 | ||
|
||
### 作用 | ||
|
||
1. 解决并发压力,提高应用处理性能(增加吞吐量,加强网络处理能力); | ||
|
||
2. 提供故障转移,实现高可用; | ||
|
||
3. 通过添加或减少服务器数量,提供网站伸缩性(扩展性); | ||
|
||
4. 安全防护;(负载均衡设备上做一些过滤,黑白名单等处理) | ||
|
||
### 分类 | ||
|
||
#### http重定向 | ||
|
||
当http代理(比如浏览器)向web服务器请求某个URL后,web服务器可以通过http响应头信息中的Location标记来返回一个新的URL。这意味着HTTP代理需要继续请求这个新的URL,完成自动跳转 | ||
|
||
##### 缺陷: | ||
|
||
1. 吞吐率限制(负责重定向的主服务器,需要高吞吐量) | ||
2. 重定向访问深度不同(重定向的资源处理时间不通,主服务器无感知) | ||
|
||
#### DNS负载均衡 | ||
|
||
通过配置域名到DNS的服务器,达到一对多的映射,相比http重定向,基于DNS的负载均衡完全节省了所谓的主站点,DNS有浏览器等的600s缓存,不用担心吞吐率限制 | ||
|
||
**一般将DNS作为第一级负载均衡,A记录对应着内部负载均衡的IP地址** | ||
|
||
##### 特性 | ||
|
||
1. 可以根据用户IP来进行智能解析。DNS服务器可以在所有可用的A记录中寻找离用记最近的一台服务器。 | ||
2. 动态DNS:在每次IP地址变更时,及时更新DNS服务器。当然,因为缓存,一定的延迟不可避免。 | ||
|
||
##### 缺点 | ||
|
||
1. 各级节点的DNS服务器不同程序的缓存会让你晕头转向 | ||
2. 无法根据实际服务器的实时负载差异来调整调度策略 | ||
|
||
#### 反向代理负载均衡 | ||
|
||
反向代理的调度器扮演的是用户和实际服务器中间人的角色 | ||
|
||
##### 特点 | ||
|
||
1. 调度策略丰富 | ||
2. 根据实时情况调整策略 | ||
3. 粘滞会话 | ||
|
||
##### 缺陷 | ||
|
||
对反向代理服务器要求高,需要keeplive监控心跳 | ||
|
||
#### IP负载均衡(LVS-NAT) | ||
|
||
在网络层通过修改请求目标地址进行负载均衡 | ||
|
||
用户请求数据包,到达负载均衡服务器后,负载均衡服务器在操作系统内核进程获取网络数据包,根据负载均衡算法得到一台真实服务器地址,然后将请求目的地址修改为,获得的真实ip地址,不需要经过用户进程处理 | ||
|
||
##### 缺点 | ||
|
||
1. 但是一旦请求的内容过大时,不论是基于反向代理还是NAT,负载均衡的整体吞吐量都差距不大 | ||
2. 网络是瓶颈,需要转发数据包 | ||
|
||
#### 链路层负载均衡(LVS-DR) | ||
|
||
数据分发时,不修改ip地址,指修改目标mac地址,配置真实物理服务器集群所有机器虚拟ip和负载均衡服务器ip地址一致,达到不修改数据包的源地址和目标地址,进行数据分发的目的,也称为直接路由模式 | ||
|
||
优点:性能好; | ||
|
||
缺点:配置复杂; | ||
|
||
#### IP隧道(LVS-TUN) | ||
|
||
LVS-DR和LVS-TUN都适合响应和请求不对称的Web服务器,如何从它们中做出选择,取决于你的网络部署需要,因为LVS-TUN可以将实际服务器根据需要部署在不同的地域,并且根据就近访问的原则来转移请求,所以有类似这种需求的,就应该选择LVS-TUN。 | ||
|
||
#### 混合型负载均衡 | ||
|
||
1. 动静分离的场景:DNS负载均衡 + 反向代理负载均衡 + IP负载均衡/链路层负载均衡 | ||
2. 动态场景:DNS负载均衡 + IP负载均衡 + 链路层负载均衡 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,8 @@ | |
- [14数据结构和算法](./14数据结构和算法/0目录.md) | ||
|
||
- [15密码学](./15密码学/0目录.md) | ||
|
||
- [16架构](./16架构/0目录.md) | ||
|
||
|
||
|
||
|