I have a multi-master MySQL cluster and I would like to distribute read/write queries coming from my Rails project to multiple servers through the use of a load balancer.
The problem is, as far as I can see, Rails tries to keep a connection object alive for the duration of the server's lifetime. However, HAProxy only distributes queries when new connections are opened per query. This is not what I want. I want distribution on a per-query basis, not per-connection basis.
What are my options for distributing rails queries from my server to multi-master servers on a per-query basis?
Note: This is a high-availability situation and we are not sure if every sql server is up at all times. This is why I use haproxy.
haproxy does load balancing on layer 4 and you need something on layer 7 that understand the mysql protocol. haproxy won't help.
"MySQL Load Balancer" was an attempt to do that, I don't know if anyone uses it in production. In this article you can see some tips on using TrafficScript for that, in the end I don't think there is any stable software that does what you want.