YugaByte provide's a smartdriver to help load balance across distributed nodes (amongst other things). In cases where this driver can't be used, one can use a proxy to achieve the same. The following are instructions to use HAProxy to do this:
- Use HAProxy with the following config (while changing/tuning the YB parameters as needed):
global
maxconn 100
defaults
log global
mode tcp
retries 2
timeout client 30m
timeout connect 4s
timeout server 30m
timeout check 5s
listen stats
mode http
bind *:7000
stats enable
stats uri /
listen yugabytedb
bind *:5000
option pgsql-check user yugabyte
default-server inter 3s fall 3
server ybnode1 10.1.0.31:5433 check port 5433
server ybnode2 10.1.0.32:5433 check port 5433
server ybnode3 10.1.0.33:5433 check port 5433
- Use Hasura with the following connection string:
postgresql://yugabyte:P@[email protected]:5000/yugabyte