If you need a High Availability (HA) setup to balance connections to your MariaDB cluster nodes, you should consider using HAProxy. HAProxy set up in a dual configuration (primary and secondary) will further contribute to your redundant HA topology. This blog is intended to describe how the key component in the dual HAProxy configuration works to ensure an HA solution.

The key component for this solution is the keepalived daemon. This important daemon is often used in conjunction with HAProxy to provide failover capability and ensure the high availability of HAProxy services. keepalived is an open-source software package used along with HAProxy to provide simple and robust facilities for load balancing and high availability in Linux-based environments. It works by monitoring the health of dual HAProxy nodes and automatically transferring service responsibility from the primary node to the secondary node in case of failure.

There are a lot of geeky, low-level details involved in how the keepalived works, but this blog’s intention is to keep it simple. Below is a simple detailed description of what the keepalived daemon does in a HAProxy dual setup:

Heartbeat Monitoring: keepalived continuously monitors the health of each node in the HAProxy dual setup by periodically sending heartbeat messages between the nodes. These heartbeat messages verify that each node is operational and able to respond.

Service Checking: In addition to monitoring the health of the nodes themselves, keepalived also checks the health of the services running on each node. For example, it can monitor the availability of HAProxy instances by checking whether they are responsive and able to handle incoming requests.

Failover Handling: If keepalived detects that a node or a service on a node has failed or become unreachable, it initiates failover procedures to ensure that services remain available. This typically involves transferring the responsibility for handling incoming requests from the failed node to the secondary or active node HAProxy.

Virtual IP Management: keepalived manages a virtual IP (VIP) address shared between the HAProxy dual setup nodes. This VIP address is the entry point for clients to access the services HAProxy provides. keepalived ensures that the VIP address is always assigned to the active node, so even if there is a failover event, clients can continue to access the services without interruption.

Configuration Synchronization: keepalived ensures that the configuration of HAProxy and other relevant components is synchronized between the nodes in the dual setup. This ensures consistency and coherence in the setup, reducing the risk of configuration drift and ensuring that failover events occur smoothly.

Load Balancing Integration: keepalived integrates with HAProxy to provide seamless failover and load-balancing capabilities. It works in conjunction with HAProxy to ensure that incoming requests are properly distributed among the active database nodes and that failover events are handled transparently to clients.

Customizable Configuration: keepalived provides a flexible and customizable configuration interface that allows administrators to define various parameters such as monitoring intervals, failover thresholds, and failover behaviors. This enables administrators to tailor the behavior of keepalived to suit the specific requirements of their HAProxy dual setup.

As you can clearly see, the keepalived daemon plays a critical role in ensuring the high availability and reliability of HAProxy services in a dual setup by continuously monitoring node and service health, orchestrating failover events when necessary, managing virtual IP addresses, and integrating seamlessly with HAProxy for load balancing and service distribution.

If your organization is looking for High Availability solutions to your MariaDB cluster topology, please don’t hesitate to contact an XTIVIA MySQL/MariaDB DBA for consultation.

Share This