Load balancing
|
NOTE
The load balancing feature is available for ADP Enterprise Edition.
|
The ADP cluster implements load balancing, which distributes client requests across multiple database replicas. This technique allows ADP to process more requests simultaneously.
ADP uses HAProxy (High Availability Proxy) to implement load balancing. HAProxy is a software TCP/HTTP load balancer. It listens on two ports: connections to one of them are transferred to the leader, requests to another are distributed across ADP nodes. Write transactions should be sent to the first port, read only transactions to the second one. If you send a write transaction to the port for read only requests, ADP refuses it.
|
NOTE
HAProxy does not check whether a current request is a write or read-only transaction. Client applications must choose the correct port for connections.
|
HAProxy chooses which node should process a client request according to specified rules. Only the leader can process write transactions. Read only transactions are passed to replicas. You can also configure HAProxy to allow the leader to process read only transactions. See Configure load balancing for details.
If PgBouncer is enabled, write transactions will be sent to a PgBouncer instance of an ADP leader node and read only transactions — to PgBouncer instances of replica nodes. See Configure PgBouncer.
The ADP uses the Etcd cluster as DCS (Distributed Configuration Store). The Patroni service that implements streaming replication stores information about ADP cluster configuration in etcd. For more information about ADP replication, see ADP high availability overview.
The conf.d service updates HAProxy configuration files when the cluster configuration changes. For example, a new node is added, or a leader is changed. The conf.d service is installed on the host with HAProxy. It subscribes on ADP cluster configuration updates stored in Etcd. When ADP changes the configuration, the conf.d service generates new configuration files for HAProxy and reloads HAProxy to apply the changes.
HAProxy also uses the Patroni REST API for additional verification which node is the leader and which is the replica.
|
TIP
To improve HAProxy high availability, you can use technologies that are not related to ADP. For example, HAProxy instances may be added as A/AAAA records with a single FQDN to DNS server. Also, the keepalived tool can be used to manage multiple HAProxy hosts.
|