RTMP负载平衡通过HAProxy

我有一个小问题要解决:

我需要find一种方法来在我的服务器上负载均衡带宽方面,传入的RTMPstream。

我有2个RTMP服务器(nginx-rtmp),我们称之为S1和S2。

RTMP服务器正在侦听1936端口, HAProxy与S1在同一台机器上对数据stream进行负载平衡,只要它在两个服务器上使用带宽,就可以正常工作。

使用当前的configuration,客户端发送一个RTMPstream,S1上的HAProxy接收它并selectS2作为接收服务器,最后将streamredirect到它。 因此,对于1Mbps的stream,S1使用1Mbbs接收数据stream,1Mbps将数据stream转发到第二台服务器,在S2上也使用1Mbps。

这里是HAProxy的configuration:

global log /dev/log local0 log /dev/log local1 notice chroot /var/lib/haproxy #user haproxy #group haproxy daemon defaults log global mode http option httplog option dontlognull contimeout 5000 clitimeout 50000 srvtimeout 50000 errorfile 400 /etc/haproxy/errors/400.http errorfile 403 /etc/haproxy/errors/403.http errorfile 408 /etc/haproxy/errors/408.http errorfile 500 /etc/haproxy/errors/500.http errorfile 502 /etc/haproxy/errors/502.http errorfile 503 /etc/haproxy/errors/503.http errorfile 504 /etc/haproxy/errors/504.http frontend ft_rtpm bind :1935 mode tcp maxconn 400 default_backend bk_rtmp backend bk_rtmp mode tcp server media01 127.0.0.1:1936 check maxconn 200 weight 1 server media02 ip.address.of.S2:1936 check maxconn 200 weight 1 

我需要find一种方法将请求直接传递给负载均衡器select的服务器,而不使用负载均衡器的带宽。

我知道这叫做HA 代理,但我希望这是可能的,同时我也search了其他解决scheme,如DNS循环,任播,DNS的SRVlogging(这是伟大的,只有当他们使用…)但它看起来不像HAProxy那样有效(没有权重,健康检查,最大连接…),因为它非常接近最终结果,因为只有带宽问题。

你正在寻找什么叫做“直接服务器返回”,简称DSR。

您不能使用HAProxy来执行DSR,但LVS或其他第4层负载均衡器可以执行此操作。 如果你刚刚做第4层,那么HAPproxy可能有点矫枉过正。