v2ray-core icon indicating copy to clipboard operation
v2ray-core copied to clipboard

A outbound of load balancing

Open Cwek opened this issue 9 years ago • 10 comments

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

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

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

以上为我的建议。

Cwek avatar Nov 10 '17 12:11 Cwek

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.

KazamaSion avatar Dec 14 '17 00:12 KazamaSion

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
}

Cwek avatar Dec 15 '17 07:12 Cwek

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.

IbarakiKasen avatar Jan 24 '18 07:01 IbarakiKasen

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

e2ge avatar Feb 22 '18 19:02 e2ge

支持

cjjdaq avatar Jul 05 '18 11:07 cjjdaq

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

evvil avatar Nov 20 '18 17:11 evvil

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

github-actions[bot] avatar Jul 18 '20 01:07 github-actions[bot]

please keep this open, stale bot

ivandeex avatar Jul 18 '20 13:07 ivandeex

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

github-actions[bot] avatar Nov 16 '20 01:11 github-actions[bot]

很有必要

20NE avatar Mar 11 '23 23:03 20NE