HAProxy Loadbalancing TCP traffic

前端 未结 1 1690
予麋鹿
予麋鹿 2021-02-01 10:36

Using HAProxy, I\'m trying to (TCP) load balance Rserve(a service listening in TCP socket for calling R scripts) running at port 6311 in 2 nodes.

Below is my config file

相关标签:
1条回答
  • 2021-02-01 10:57

    After struggling for a week for a solution to load balance R, below (full free/open source software stack) solution worked.

    If more people are referring this, I'll post a detailed blog on installation to configuration.

    Was able to load balance R script requests coming to Rserve via HAProxy TCP load balancer with the below config. Pretty much similar to config in question section, but with frontend and backend separated.

    #Load balancer stats page access at hostname:8080/haproxy_stats
    listen stats <load_balancer_hostname>:8080
        mode http
        log global
        stats enable
        stats realm Haproxy\ Statistics 
        stats uri /haproxy_stats
        stats hide-version
        stats auth admin:admin@rserve
    
    frontend rserve_frontend
        bind *:81
        mode tcp
        option tcplog
        timeout client  1m
        default_backend rserve_backend
    
    backend rserve_backend
        mode tcp
        option tcplog
        option log-health-checks
        option redispatch
        log global
        balance roundrobin
        timeout connect 10s
        timeout server 1m   
        server rserve1 <rserve hostname1>:6311 check
        server rserve2 <rserve hostname2>:6311 check
        server rserve2 <rserve hostname3>:6311 check
    

    Key thing is to enable remote connections for HAproxy with the below command(NO clear doc on this in most part)

    /usr/sbin/setsebool -P haproxy_connect_any 1
    

    Also make sure enable remote connections in Rserve with "enable remote" param in Rserve config file.

    0 讨论(0)
提交回复
热议问题