Skip to content

Instantly share code, notes, and snippets.

@dsandip
Created February 26, 2024 16:54
Show Gist options
  • Save dsandip/b554d39b525ce969f6f93b43e050e4a3 to your computer and use it in GitHub Desktop.
Save dsandip/b554d39b525ce969f6f93b43e050e4a3 to your computer and use it in GitHub Desktop.
HA Proxy configuration for YugaByte

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:

  1. 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
  1. Use Hasura with the following connection string:

postgresql://yugabyte:P@[email protected]:5000/yugabyte

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment