On 9 September 2011 13:49, John Helliwell <john.helliw...@gmail.com> wrote: > > I'm trying to have haproxy send requests to 4 backends which are redis > servers. Only one of the four is master, and the other 3 are slaves. > I want to health check by sending an INFO command, to which redis will reply > > $640 > redis_version:1.3.15
> If the response from the check includes the reply "role:master", I want the > health check to succeed, else fail. > listen redis localhost:6379 > mode tcp > ... > option httpchk INFO \r\n > http-check expect rstring master > I know I'm trying to do something odd with httpchk, and perhaps I need to > craft a better regexp for my expect string. > Could anyone assist? Hi John The "something odd" you are doing is attempting to use the httpchk option to speak a non-HTTP application protocol. Using the "check" option in server definitions will make HAproxy check if it can successfully establish a TCP connection to the IP/port for the server. Successful connection == successful health check. There isn't a way to send a specific command to the application (INFO in your case), nor parse for specific reponse/s. Using "option httpchk" allows us to do smarter health checks when a backend is speaking HTTP. It sends a specifically crafted HTTP request, and HAproxy will expect responses with specific HTTP response codes. This can be further fine-tuned using "http-check expect ...". Unfortunately, redis does not speak HTTP, and thus you cannot use "option httpchk" or "http-check expect ..." with it. Your health check options are limited to testing TCP connectivity to the IP/port of each server. Regards, Graeme.