V2ray-core: A outbound of load balancing

Created on 10 Nov 2017  ·  9Comments  ·  Source: v2ray/v2ray-core

可能有一些外部工具用于实现出口的负载平衡,但希望能在V2Ray里面实现这个功能从而方便配置,而且outbound好像支持proxySettings参数来指向其他outbound作为出口。

我建议提供三种选择模式,每个外出的链接根据选择模式由选择器选出一个作为出口
1.等概率,列出一堆作为outbound的数组,然后每次外出链接建立时随机选出一个。
2.按比例,列出一个以0.01~1的数字为键,outbound的tag为值的对象数组,键的和为1。每次外出链接建立时根据前几次按比例随机抽选。
3.轮盘式,列出一堆作为outbound的数组,然后每次外出链接建立时轮流选出一个,循环使用。

同时建立一个固定出口机制,一个特定目的地址和端口为唯一标记,第一次建立时记下选中的出口,之后每次建立同一个标记的链接刷新接触时间和分配相同的出口,直到超过特定时间或出口无法建立(链接出错)时消除该记录,重新选择出口。

以上为我的建议。

Stale

Most helpful comment

Active Health Checks should be one of them. If one server is down. It can be disabled automatically. The config may seems like this:

{
  "protocol": "protocol",
  "settings": {
    "servers": [{
        "sth": "is here",
        "health_check": {
            "max_fails": 5,
            "period": 60, // 5 times in 60 seconds
            "slow_start": 300 // the server is available again when it ups for 300 seconds   
        }
      }
    ]
  }
}

BTW, max connections config is also a good choice to blance proxy servers, for example:

{
  "protocol": "protocol",
  "settings": {
    "servers": [{
        "sth": "is here",
        "max_conns": "50"
      },
      {
        "sth": "is here",
        "max_conns": "20"
      }
    ]
  }
}

Ideas from nginx.

All 9 comments

Active Health Checks should be one of them. If one server is down. It can be disabled automatically. The config may seems like this:

{
  "protocol": "protocol",
  "settings": {
    "servers": [{
        "sth": "is here",
        "health_check": {
            "max_fails": 5,
            "period": 60, // 5 times in 60 seconds
            "slow_start": 300 // the server is available again when it ups for 300 seconds   
        }
      }
    ]
  }
}

BTW, max connections config is also a good choice to blance proxy servers, for example:

{
  "protocol": "protocol",
  "settings": {
    "servers": [{
        "sth": "is here",
        "max_conns": "50"
      },
      {
        "sth": "is here",
        "max_conns": "20"
      }
    ]
  }
}

Ideas from nginx.

The config file looks like:

{
  "protocol": "balanout",  
  "tag": "tag",
  "settings": {
     "switchType" : "equiprobability", //equiprobability, proportionally, roulette
     "outbounds" : ["outbound_tag1", "outbound_tag2", ...], //if switchtype is equiprobability or roulette
                           {"0.1":"outbound_tag1", "0.2":"outbound_tag2", ...  }, //if switchtype is proportionally
     "outlinkFixation" : true, //switch to control the fixation of outbound when it go out in the frist time.
     "fixationCleanInterval" : 86400 //the time to clean the relation of the outlink and outbound which it use. unit is second
  },  
  "proxySettings": null //can't be set beacause it use the same function of the outbound proxy
}

An alternative way is to add a routing rule that will match each connection with a given probability, or by a given pattern. Idea from iptables.

specify multiple tags in "outboundTag" is a alternative way.

支持

还有同host目标网站使用一个ip

This issue is stale because it has been open 120 days with no activity. Remove stale label or comment or this will be closed in 5 days

please keep this open, stale bot

This issue is stale because it has been open 120 days with no activity. Remove stale label or comment or this will be closed in 5 days

Was this page helpful?
0 / 5 - 0 ratings