0

I've got a little problem to solve:

I need to find a way to load balance, bandwidth-wise, the incoming RTMP streams on my servers.

I have 2 RTMP servers (nginx-rtmp), let's call them S1 and S2.

The RTMP servers are listening on the 1936 port, with HAProxy on the same machine as S1 to load-balance the streams, and as of the moment it works well, except that it uses the bandwidth on BOTH servers.

With the current configuration, the client sends a RTMP stream, HAProxy on S1 receives it and chooses S2 as the receiving server, and finally redirects the stream to it. So, for a 1Mbps stream, S1 uses 1Mbbs to receive the stream and 1Mbps to forward it to the second server, which is also using 1Mbps on S2.

Here's the configuration of HAProxy:

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 

I need to find a way to pass the requests directly to the server the load-balancer has chosen, without using the bandwidth of the load-balancer.

I know it's called HAProxy but I hoped it would be possible, so meanwhile I've also searched about other solutions like DNS round-robin, Anycast, DNS's SRV records (which are great, only if they were used...), but it doesn't seem as effective as HAProxy (no weights, health checks, max connections...), as it is very close to the final result, as there's "only" the bandwidth problem.

2
  • Shouldn't your HAProxy be running on dedicated hardware, so that you can point it to the two media servers, S1 and S2? Commented Jul 1, 2015 at 1:50
  • Yes it should, I only own 2 servers because it's expensive, so I run HAProxy on the most powerful one. I believe it doesn't change the bandwidth problem though, which will be the bottleneck if it isn't fixed. Commented Jul 1, 2015 at 1:54

1 Answer 1

1

What you're looking for is called 'Direct Server Return', or DSR for short.

You can't do DSR with HAProxy, but LVS or other layer 4 load-balancers can do it. If you've just doing layer 4, then HAPproxy might be a little overkill anyway.

4
  • I've never heard about it before and it's just what I needed, thank you so much ! I guess I'm heading back to configuring some stuff now :) Commented Jul 1, 2015 at 17:05
  • Hi Could you please guide me on load balancer? I am pretty new to this domain. My current setup is OBS -> RTMP server <- Cloud front <- User. I want a load balancer in between OBS and RTMP servers so that multiple instance of RTMP servers can be launched. Thanks. Commented Jun 3, 2021 at 17:10
  • @skygeek if you have a specific question, or problem, I’d suggest asking it as a new question. Commented Jun 6, 2021 at 22:38
  • @GregL Sure. Can you please review this and help me? serverfault.com/questions/1065958/… Commented Jun 7, 2021 at 11:39

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.