HAProxy and MySQL

From: Evgeniy Sudyr <eject.in.ua#gmail.com>
Date: Fri, 7 Aug 2009 17:54:26 +0300


Hi, I'm trying to use HAProxy as round robin load balancer for 2 MySQL servers. I'm using mysqlslap for benchmarking.

At the moment I figured that load balanced connection is slowest in times. I need explanation from HAProxy experts why ?

There is my config:
cat /etc/haproxy/haproxy.cfg

global

        maxconn 2000
        pidfile /var/run/haproxy.pid
        user _haproxy
        group _haproxy

defaults
        retries 3
        maxconn 2000
        contimeout      5000
        clitimeout      50000
        srvtimeout      50000

listen MySQL 192.168.100.254:3306
        mode tcp
        balance roundrobin
        option  persist
        server mysql1 192.168.100.131:3306
        server mysql2 192.168.100.132:3306


*There is my test results:*

HA Proxy Load balancer QUERY1

mysqlslap -u root --password=password -a -h 192.168.100.254 Benchmark

        Average number of seconds to run all queries: 0.125 seconds
        Minimum number of seconds to run all queries: 0.125 seconds
        Maximum number of seconds to run all queries: 0.125 seconds
        Number of clients running queries: 1
        Average number of queries per client: 0

HA Proxy Load balancer QUERY2

mysqlslap -u root --password=password -a -h 192.168.100.254 Benchmark

        Average number of seconds to run all queries: 0.125 seconds
        Minimum number of seconds to run all queries: 0.125 seconds
        Maximum number of seconds to run all queries: 0.125 seconds
        Number of clients running queries: 1
        Average number of queries per client: 0

 MySQL SERVER1

mysqlslap -u root --password=password -a -h 192.168.100.131 Benchmark

        Average number of seconds to run all queries: 0.015 seconds
        Minimum number of seconds to run all queries: 0.015 seconds
        Maximum number of seconds to run all queries: 0.015 seconds
        Number of clients running queries: 1
        Average number of queries per client: 0

 MySQL SERVER2
mysqlslap -u root --password=password -a -h 192.168.100.132 Benchmark

        Average number of seconds to run all queries: 0.015 seconds
        Minimum number of seconds to run all queries: 0.015 seconds
        Maximum number of seconds to run all queries: 0.015 seconds
        Number of clients running queries: 1
        Average number of queries per client: 0


---
Thanks!
Evgeniy Sudyr
Received on 2009/08/07 16:54

This archive was generated by hypermail 2.2.0 : 2009/08/07 17:00 CEST