Commit 87e8240c authored by ChenHongyu's avatar ChenHongyu

README.md

parent d560a1fb
# 基于 Etcd 和 gRPC 的负载均衡 # 基于 Etcd 和 gRPC 的负载均衡
...@@ -47,27 +49,43 @@ round-robin会对 address 去重, 所以要加一些信息 ...@@ -47,27 +49,43 @@ round-robin会对 address 去重, 所以要加一些信息
## roundrobin策略
## 基于roundrobin负载策略实现按权轮询
## lb_demo1 roundrobin策略
普通地轮询
## lb_demo2 基于roundrobin策略实现按权轮询
根据权重加入多个重复的 addr, 然后轮询, 实现带权轮询的效果
## lb_demo3 自定义负载策略实现按权轮询
![image-20210601184546643](image/image-20210601184546643.png)
## 自定义负载策略实现按权轮询 在构造 `resolver.Address` 时将 `weight` 作为`*attributes.Attributes`附加值代入
![image-20210601184042079](image/image-20210601184042079.png)
重构 Build 和 Pick 接口, 使用 Build 构造[]balancer.SubConn列表, 然后用 Pick 在列表中选出接收请求的通道
示例代码仓库 ## 示例代码仓库
- [ChenHongyu / go-etcd-grpc-load-balance · GitLab (33.cn)](https://gitlab.33.cn/chy/go-etcd-grpc-load-balance) - [ChenHongyu / go-etcd-grpc-load-balance · GitLab (33.cn)](https://gitlab.33.cn/chy/go-etcd-grpc-load-balance)
参考文档 ## 参考文档
- [grpc-go基于etcd实现服务发现机制](http://morecrazy.github.io/2018/08/14/grpc-go%E5%9F%BA%E4%BA%8Eetcd%E5%AE%9E%E7%8E%B0%E6%9C%8D%E5%8A%A1%E5%8F%91%E7%8E%B0%E6%9C%BA%E5%88%B6) - [grpc-go基于etcd实现服务发现机制](http://morecrazy.github.io/2018/08/14/grpc-go%E5%9F%BA%E4%BA%8Eetcd%E5%AE%9E%E7%8E%B0%E6%9C%8D%E5%8A%A1%E5%8F%91%E7%8E%B0%E6%9C%BA%E5%88%B6)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment