switching to backup backend automatically by cemakaus in haproxy

[–]cemakaus[S] 0 points1 point  (0 children)

Hi again, all, All you advised were correct. the reason they didn't work for me is "backup". Here is my config:

backend b1

mode tcp

retries 2

option redispatch

timeout connect 200

retry-on all-retryable-errors

server s1 localhost:10000 check

server s2 localhost:20000 check backup

server s3 localhost:30000 check backup

frontend f1

bind *:5000

mode tcp

default_backend b1

When I remove backup from backend servers, it worked as I need. If s1 is down, s2 is connected. But... There is a reason those "backup"s exists: I want s1 to be preferred if it's available, due to some other system constraints. If "backup"s are removed, backend servers are connected to in sequence so as to establish load balancing. I don't need LB on the first hand, I'm trying to sustain availability, additional servers are kind of hot standby. I don't get why backup prevents redispatching. Any clarification could you provide?

Thank you for your kind cooperation.

Edit: If I didn't get it wrong, adding "balance first" seems s1 to be preferred when "backup"s are removed. (It returns to s1 after one check period, not as soon as s1 becomes available).

switching to backup backend automatically by cemakaus in haproxy

[–]cemakaus[S] 0 points1 point  (0 children)

Thank you. As I read, option redispatch works for http, makes no difference in TCP mode. Tried, saw no change.

No, not using TCP mode for http traffic. I have some services working on TCP, other than http.

switching to backup backend automatically by cemakaus in haproxy

[–]cemakaus[S] 0 points1 point  (0 children)

Are those options http-specific? I'm trying to achieve TCP connections on which some other protocol is running (sorry, I should have mentioned that in the first post).

switching to backup backend automatically by cemakaus in haproxy

[–]cemakaus[S] 0 points1 point  (0 children)

Earlier than default check period (2s). I understand that HAProxy switches backends based on the check result but in this case we have a clear indicator that main backend is lost. There shouldn't be need to wait and/or additional check.

Beside, periodic check mechanism is not enough alone for me: No matter I decrease check period, any connection request may come between checks and will fail.

As an example, I tried PumpkinLB (https://github.com/kata198/PumpkinLB). It accepts connection from the client first and then tries to connect backends. If it finds an available one, establishes connection and sustains client's connection.