MySQL + HAProxy

echo "net.ipv4.ip_nonlocal_bind=1" >> /etc/sysctl.conf
echo "net.ipv4.tcp_tw_reuse=1" >> /etc/sysctl.conf
echo "net.ipv4.ip_local_port_range = 1024 65023" >> /etc/sysctl.conf
echo "net.ipv4.tcp_max_syn_backlog=40000" >> /etc/sysctl.conf
echo "net.ipv4.tcp_max_tw_buckets=400000" >> /etc/sysctl.conf
echo "net.ipv4.tcp_max_orphans=60000" >> /etc/sysctl.conf
echo "net.ipv4.tcp_synack_retries=3" >> /etc/sysctl.conf
echo "net.core.somaxconn=40000" >> /etc/sysctl.conf
echo "net.ipv4.tcp_fin_timeout=5" >> /etc/sysctl.conf
/etc/haproxy/haproxy.cfg
global
        pidfile /var/run/haproxy.pid
        daemon
        user nobody
        group nobody
        stats socket /tmp/haproxy.socket user nobody group nobody mode 600 level admin
        node NODE_NAME
        description NODE_DESC
        #* Performance Tuning
        maxconn 40000
        spread-checks 3
        quiet
defaults
        #log   global
        mode   tcp
        option dontlognull
        option tcp-smart-accept
        option tcp-smart-connect        
        option redispatch
        retries 3
        maxconn 40000
        timeout check   3500ms
        timeout queue   3500ms
        timeout connect 3500ms
        timeout client  10000ms
        timeout server  10000ms

listen STATS
        bind 0.0.0.0:8080
        mode http
        stats enable
        stats uri /
        stats realm Strictly\ Private
        stats auth admin:P@ssw0rd
        stats auth user1:passwd1

listen RW
        bind *:3001
        option mysql-check user haproxy post-41
        server mysql-1 10.0.0.1:3306 check fall 2 inter 1000
        server mysql-2 10.0.0.2:3306 check fall 2 inter 1000 backup

listen RO
        bind *:3002
        balance leastconn        
        option mysql-check user haproxy post-41
        server mysql-1 10.0.0.1:3306 check fall 2 inter 1000
        server mysql-2 10.0.0.2:3306 check fall 2 inter 1000

> mysql
USE mysql;
INSERT INTO user (Host,User) values ('','haproxy');
FLUSH PRIVILEGES;