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.

  • Shouldn't your HAProxy be running on dedicated hardware, so that you can point it to the two media servers, S1 and S2? – Tim Jul 1 '15 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. – Canardlaquay Jul 1 '15 at 1:54
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.

  • 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 :) – Canardlaquay Jul 1 '15 at 17:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.