两个不错的可以实现均衡负载的 go 库,sslb 比较简单,seesaw 功能较多,使用也比较复杂。
sslb - Golang超级简单的负载均衡,比较简单,支持 WebSockets
https://github.com/eduardonunesp/sslb
google 非官方团队开源的,基于LVS
https://github.com/google/seesaw
sslb 示例
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
{
"general": {
"maxProcs": 4,
"workerPoolSize": 10,
},
"frontends" : [
{
"name" : "Front1",
"host" : "127.0.0.1",
"port" : 9000,
"route" : "/",
"timeout" : 5000,
"backends" : [
{
"name" : "Back1",
"address" : "http://127.0.0.1:9001",
"heartbeat" : "http://127.0.0.1:9001",
"inactiveAfter" : 3,
"heartbeatTime" : 5000,
"retryTime" : 5000
},{
"name" : "Back2",
"address" : "http://127.0.0.1:9002",
"heartbeat" : "http://127.0.0.1:9002",
"inactiveAfter" : 3,
"heartbeatTime" : 5000,
"retryTime" : 5000
}
]
}
]
}
本文网址: https://golangnote.com/topic/130.html 转摘请注明来源