Random Host Load Balancing: Quick Tip

Posted February 11, 2019 by James Knicely, Vertica Field Chief Technologist

High angle view of Beijing Guomao.

Native connection load balancing is a feature built into the Vertica server and client libraries that helps spread the CPU and memory overhead caused by client connections across the hosts in the database. It can prevent unequal distribution of client connections among hosts in the cluster. Typically folks implement the ROUNDROBIN load balancing scheme which chooses the next host from a circular list of hosts in the cluster that are up. However, there is another load balancing schema available called RANDOM that randomly chooses a host from among all hosts in the cluster that are up!

Example:

[dbadmin ~]$ vsql -c "SELECT node_name FROM nodes;"
node_name
------------------
v_vmart_node0001
v_vmart_node0002
v_vmart_node0003
v_vmart_node0004
v_vmart_node0005
v_vmart_node0006
v_vmart_node0007
v_vmart_node0008
v_vmart_node0009
(9 rows)

[dbadmin~]$ vsql -c "SELECT set_load_balance_policy('RANDOM');"

set_load_balance_policy
----------------------------------------------------------------------------
Successfully changed the client initiator load balancing policy to: random
(1 row)

[dbadmin~]$ vsql -Cc "SELECT local_node_name();"

local_node_name
------------------
v_vmart_node0002
(1 row)

[dbadmin~]$ vsql -Cc "SELECT local_node_name();"

local_node_name
------------------
v_vmart_node0005
(1 row)

[dbadmin~]$ vsql -Cc "SELECT local_node_name();"

local_node_name
------------------
v_vmart_node0001
(1 row)

[dbadmin~]$ vsql -Cc "SELECT local_node_name();"

local_node_name
------------------
v_vmart_node0008
(1 row)

[dbadmin~]$ vsql -Cc "SELECT local_node_name();"

local_node_name
------------------
v_vmart_node0007
(1 row)

[dbadmin~]$ vsql -Cc "SELECT local_node_name();"

local_node_name
------------------
v_vmart_node0003
(1 row)

Helpful Link:

https://www.vertica.com/docs/latest/HTML/Content/Authoring/AdministratorsGuide/ManagingClientConnections/LoadBalancing/Legacy/LegacyClusterLoadBalancing.htm

Have fun!