Quantcast
Channel: HAProxy community - Latest topics
Viewing all articles
Browse latest Browse all 4849

Balance requests to first or specific server in the list

$
0
0

Hello,

we have some backend services stretched over 3 datacenters. In each datacenter we use haproxy as a backend load balancer between application and the service. we have for each haproxy instance a vip, so that the application can connect to the haproxy instances within the same datacenter.

What we like to achieve is that haproxy prefers the service instance within its own datacenter and only balance requests to the other datacenters if the “local” one fails. Just for optimal traffic flows and lower latency for the time no failure occurs.

We identified the balance option “first” as one solution:

first The first server with available connection slots receives the
connection. The servers are chosen from the lowest numeric
identifier to the highest (see server parameter “id”), which
defaults to the server’s position in the farm.

This is the backend configuration:

backend be-rabbitmq-prod-01 from rabbit_defaults
    description "RabbitMQ Cluster prod.01"
    mode tcp
    retries 3
    timeout queue 30s
    timeout connect 10s
    timeout client 3h
    timeout server 3h
    timeout check 5s
    maxconn 500
    balance first

    http-check expect status 200
    option httpchk OPTIONS /api/health/checks/is-in-service
    option srvtcpka

    default-server send-proxy-v2-ssl check check-ssl port 15671 inter 5s fastinter 2s downinter 2s rise 2 fall 2 init-state up on-marked-down shutdown-sessions
    server rabbit-02 rabbit-02.local:5671
    server rabbit-01 rabbit-01.local:5671
    server rabbit-03 rabbit-03.local:5671

Is it correct that the default numeric identifier (server parameter “id”) is equal to the server’s position in the farm like the docs states or do we have to define the id by ourselves to ensure that only the first server in the list will get all the requests?

The second solution would be to define the other servers in the list as “backup” and use leastconn oder roundrobin as balance option.

Here the question, is the failover time the same regardless using balance “first” or the “backup” solution? From our understanding this should be the same since the next server will only be used if the “first” server is marked as failed due to heath check params, right?

Or does anyone here has a handy solution for this?

Many thanks!

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 4849

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>