7.12.4. Using the Connector with HAProxy

Tungsten Connector can be used in combination with an HAProxy installation to provide a high-availability connection to the underlying connectors that then provide an intelligent connection to the datasources within the cluster.

There are multiple ways to monitor MySQL health via HAProxy, two which are recommended and one which is not (mysql-check, because this method will flood the Connector logs with connection failure messages):

  • check - an HAProxy-native test

    Adding check to each server line tells HAProxy to perform regular health checks on that backend server. By default, it will try opening a TCP connection and if the TCP handshake succeeds, HAProxy considers that server "up" and if it fails (e.g., no SYN/ACK), the server is marked "down" until it passes again. Without the check option, HAProxy assumes the server is always available and will continue sending traffic to it even if it’s unreachable.

    • BRIDGE MODE - ❌ NOT RECOMMENDED

      When the Connector is in Bridge mode, using the native test check will generate errors in the connector logs (as well as in the MySQL error log with MySQL versions 8+).

    • PROXY MODE - ✅ RECOMMENDED, with Limitations

      When the Connector is in Proxy mode, it will be considered as up as long as it is running, even if no database backend is available. This has a very low impact on the cluster as the connection will only affect the connector, but it does not guarantee the application will get a proper connection to the database due to the TCP-only nature of the test.

  • External Check Script Via systemd

    ✅ RECOMMENDED

    This script is normally launched via systemd, and allows for custom monitoring of the database health. This is the preferred method when full database visibility is needed.

  • External Check Script Via xinetd

    ✅ RECOMMENDED, but Obsolete

    This script is normally launched via xinetd, and allows for custom monitoring of the database health. This was the preferred method when full database visibility is needed.

  • mysql-check - an HAProxy-native test

    • BRIDGE MODE - ❌ NOT RECOMMENDED

      When the Connector is in Bridge mode, using the native test mysql-check will generate errors in the connector logs (as well as in the MySQL error log with MySQL versions 8+).

    • PROXY MODE -

      When the Connector is in Proxy mode, using the native test mysql-check can be done in two ways, with a MySQL user name specified (supported), and without a MySQL user name (deprecated).

      With a User Name - ✅ RECOMMENDED - If you specify a username, the check consists of sending two MySQL packets, one Client Authentication packet, and one QUIT packet, to correctly close the MySQL session. HAProxy then parses the MySQL Handshake Initialization packet and/or Error packet. The Tungsten Connector will attempt to connect to a data source in the cluster - if none is available, the check will fail and HAProxy will consider this Tungsten Connector as a dead backend. This makes it a useful test which does not produce errors or aborted connects on the server.

      Without a user Name - ❌ NOT RECOMMENDED - If you do not specify a username (this config is deprecated by HAProxy), the check only consists of parsing the MySQL Handshake Initialization packet or Error packet. The Connector will be considered as up as long as it is running, even if no database backend is available. Not recommended due to deprecation.

At the end is a an example haproxy.cfg file for a composite cluster, see: Section 7.12.4.5, “Example HAProxy Configuration File”

Exhaustive documentation can be found directly on the HA Proxy documentation page.

Additional configuration examples are located on the HA Proxy config tutorials page.