Load Balancing
When deploying multiple FE nodes, users can deploy a load balancing layer on top of the FEs to achieve high availability.
The following are some high availability options:
Code approach
One way is to implement code at the application layer to perform retry and load balancing . For example, if a connection is broken, it will automatically retry on other connections. This approach requires users to configure multiple FE node addresses.
JDBC Connector
JDBC connector supports automatic retry:
jdbc:mysql:loadbalance://[host1][:port],[host2][:port][,[host3][:port]]...[/[database]][?propertyName1=propertyValue1[&propertyName2=propertyValue2]...]
ProxySQL
ProxySQL is a MySQL proxy layer that supports read/write separation, query routing, SQL caching, dynamic load configuration, failover, and SQL filtering.
StarRocks FE is responsible for receiving connection and query requests, and it’s horizontally scalable and highly available. However FE requires users to set up a proxy layer on top of it to achieve automatic load balancing. See the following steps for setup:
1. Install relevant dependencies
yum install -y gnutls perl-DBD-MySQL perl-DBI perl-devel
2. Download the installation package
wget https://github.com/sysown/proxysql/releases/download/v2.0.14/proxysql-2.0.14-1-centos7.x86_64.rpm
3. Decompress to the current directory
rpm2cpio proxysql-2.0.14-1-centos7.x86_64.rpm | cpio -ivdm
4. Modify the configuration file
vim ./etc/proxysql.cnf
Direct to a directory that the user has privilege to access (absolute path):
datadir="/var/lib/proxysql"
errorlog="/var/lib/proxysql/proxysql.log"