GolangNote

Golang笔记

推荐两个用Go 实现的负载均衡

Permalink

两个不错的可以实现均衡负载的 go 库,sslb 比较简单,seesaw 功能较多,使用也比较复杂。

sslb - Golang超级简单的负载均衡,比较简单,支持 WebSockets

https://github.com/eduardonunesp/sslb

google 非官方团队开源的,基于LVS

https://github.com/google/seesaw

sslb 示例

JSON: 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 转摘请注明来源

Related articles

Golang 实现 10 进制转 N 进制

给定一个不没有重复字符的字符串,如 `[0-9,a-z]`,把一个 10 进制数字转为,该字符集的字符串。应用场合如汽车牌、顺序计数。...

Write a Comment to "推荐两个用Go 实现的负载均衡"

Submit Comment Login
Based on Golang + fastHTTP + sdb | go1.22.3 Processed in 0ms