In ha-proxy I separated my traffic to two frontend ports and created two backends. Port-1 traffic is directed both backend and port 2 traffic is directed two backend-2. I want to create a smart load balancer that detects if backend 2 is busy whit port 2 queries it will automatically send the traffic of port 1 to backend 1.
global
log /dev/log local0
log /dev/log local1 notice
maxconn 3000
user haproxy
group haproxy
daemon
stats socket /etc/haproxy/haproxysock level admin
# external-check
defaults
log global
timeout connect 60000
timeout client 6000000
timeout server 6000000
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 test_1
mode tcp
bind 0.0.0.0:74474
acl dp1 dst_port 34475
use_backend test_two if dp1
default_backend test_one
backend test_one
balance leastconn
mode tcp
# option external-check
option allbackups
server server-1 192.128.22.1:25554 check
server server-2 10.128.66.53:25554 check
backend test_two
balance leastconn
mode tcp
# option external-check
option allbackups
server server-1 192.168.22.1:25554 check