Search code examples
mysqlreplicationhaproxy

MySQL Replication: Using HAProxy and an HTTP-Check


I read the Github engineering article on MySQL Replication with HAProxy. One paragraph of note to me is:

In this situation, HAProxy no longer uses a mysql-check but rather an http-check. The MySQL backend server provides an HTTP interface, responding with HTTP 200 or HTTP 503 depending on replication lag. HAProxy will interpret these as “good” (UP) or “bad” (DOWN), respectively.

I am not aware of any MySQL HTTP Service. Is this a custom script that I have to write to provide this type of http-check?


Solution

  • MySQL does not provide an http service to report its slave lag.

    If you read further in the article you linked to, they wrote a section heading "Implementing the check script" which describes the custom script they wrote to provide this report.

    They link to the script, which is written in bash:

    https://github.com/github/mysql-haproxy-xinetd/blob/master/scripts/xinetd-mysql-check-lag