Tag Archives: HaProxy for MySQL

Using HaProxy for MySQL



You can also use HaProxy for MySQL traffic if you have master-master replication configured. This can be implemented in tcp mode.

As I stated in the previous article, in the tcp mode HaProxy simply delivers all traffic on the server behind the balancer.

If you have a master-slave replication I’d recommend to use mysql-proxy to distribute select, update, insert queries between servers depending on their role.

Please find the configuration example below:

####
# Description of the sql servers
####

listen mysql-proxy *:3306
 mode tcp
 balance roundrobin
 option tcplog
server SQL01 192.168.10.21:3306 check port 3306
server SQL02 192.168.10.22:3306 check port 3306
server SQL02 192.168.10.23:3306 check port 3306

Unfortunately HaProxy doesn’t know how to distribute the selects and inserts/updates between nodes. It can distribute all connections.

Share Button