Load balancing MySQL with HaProxy. Peter Boros Consultant @ Percona 4/23/13 Santa Clara, CA



Similar documents
Configuring HAproxy as a SwiftStack Load Balancer

HAProxy. Ryan O'Hara Principal Software Engineer, Red Hat September 17, HAProxy

CS312 Solutions #6. March 13, 2015

Native SSL support was implemented in HAProxy 1.5.x, which was released as a stable version in June 2014.

EMC VIPR SRM 3.7: GUIDELINES FOR CONFIGURING MULTIPLE FRONTEND SERVERS

High Availability Cluster Solutions for Ubuntu14.04 on Power

ALOHA LOAD BALANCER MANAGING SSL ON THE BACKEND & FRONTEND

HaProxy możliwości i zastosowania. Marek Oszczapiński m.oszczapiński@polskapresse.pl

FILECLOUD HIGH AVAILABILITY

Application Note. Active Directory Federation Services deployment guide

Availability Digest. Redundant Load Balancing for High Availability July 2013

vrealize Operations Manager Load Balancing

Load Balancing Web Proxies Load Balancing Web Filters Load Balancing Web Gateways. Deployment Guide

Web Load Balancing on a Budget

Load Balancing McAfee Web Gateway. Deployment Guide

Load Balancing Barracuda Web Filter. Deployment Guide

MySQL Performance Blog. Measuring failover time for ScaleArc load balancer

Session Storage in Zend Server Cluster Manager

Load Balancing Sophos Web Gateway. Deployment Guide

Load Balancing Clearswift Secure Web Gateway

HAProxy. Free, Fast High Availability and Load Balancing. Adam Thornton 10 September 2014

Load Balancing Oracle Application Server (Oracle HTTP Server) Quick Reference Guide

Load Balancing Bloxx Web Filter. Deployment Guide

How to Make the Client IP Address Available to the Back-end Server

Application Note. Lync 2010 deployment guide. Document version: v1.2 Last update: 12th December 2013 Lync server: 2010 ALOHA version: 5.

Load Balancing Trend Micro InterScan Web Gateway

Introducing the Microsoft IIS deployment guide

Load Balancing Microsoft Terminal Services. Deployment Guide

High Availability Using MySQL in the Cloud:

Scaling Next-Generation Firewalls with Citrix NetScaler

TFE listener architecture. Matt Klein, Staff Software Engineer Twitter Front End

Load Balancing Microsoft Sharepoint 2010 Load Balancing Microsoft Sharepoint Deployment Guide

ALOHA Load-Balancer. Microsoft Exchange 2010 deployment guide. Document version: v1.4. ALOHA version concerned: v4.2 and above

Microsoft Lync Server Overview

Smoothwall Web Filter Deployment Guide

Snapt Balancer Manual

Deployment Guide Oracle Siebel CRM

Load Balancing Microsoft AD FS. Deployment Guide

Migrating the SSL Offloading Configuration of the Alteon Application Switch 2424-SSL to AlteonOS version

High Availability Solutions for the MariaDB and MySQL Database

Deploying the Barracuda Load Balancer with Office Communications Server 2007 R2. Office Communications Server Overview.

Load Balancing VMware Horizon View. Deployment Guide

Load Balancing VMware Horizon View. Deployment Guide

Load Balancing Smoothwall Secure Web Gateway

Deliverable D6.6. Performance testing of cloud applications, Interim Release

Microsoft Lync 2010 Deployment Guide

TESTING & INTEGRATION GROUP SOLUTION GUIDE

Basic & Advanced Administration for Citrix NetScaler 9.2

ClusterLoad ESX Virtual Appliance quick start guide v6.3

Qualogy M. Schildmeijer. Whitepaper Oracle Exalogic FMW Optimization

Apache Tomcat Clustering

How To Balance A Load Balancer On A Server On A Linux (Or Ipa) (Or Ahem) (For Ahem/Netnet) (On A Linux) (Permanent) (Netnet/Netlan) (Un

Oracle Communications WebRTC Session Controller: Basic Admin. Student Guide

WebGUI Load Balancing

Direct NFS - Design considerations for next-gen NAS appliances optimized for database workloads Akshay Shah Gurmeet Goindi Oracle

Deliverable D6.7. Performance testing of cloud applications, Final Release

Load Balancing Microsoft Lync 2010 Load Balancing Microsoft Lync Deployment Guide

Load Balancing RSA Authentication Manager. Deployment Guide

Load Balancing BEA WebLogic Servers with F5 Networks BIG-IP v9

Deploying Microsoft SharePoint Services with Stingray Traffic Manager DEPLOYMENT GUIDE

Implementing Internet Storage Service Using OpenAFS. Sungjin Dongguen Arum

Configuring Nex-Gen Web Load Balancer

Pertino HA Cluster Deployment: Enabling a Multi- Tier Web Application Using Amazon EC2 and Google CE. A Pertino Deployment Guide

Jive and High-Availability

Flexible Routing and Load Control on Back-End Servers. Controlling the Request Load and Quality of Service

F5 Configuring BIG-IP Local Traffic Manager (LTM) - V11. Description

ExamPDF. Higher Quality,Better service!

ZEN LOAD BALANCER EE v3.04 DATASHEET The Load Balancing made easy

ZEN LOAD BALANCER EE v3.02 DATASHEET The Load Balancing made easy

Application Delivery Controller (ADC) Implementation Load Balancing Microsoft SharePoint Servers Solution Guide

Veriton. Getting the Best out of Hardware Load Balancers in an Oracle Environment. What is a Load Balancer? Agenda. What s out there?

Load Balancing Microsoft Exchange Deployment Guide

Load Balancing IBM Lotus Instant Messaging and Web Conferencing Servers with F5 Networks BIG-IP System

DEPLOYMENT GUIDE Version 1.1. DNS Traffic Management using the BIG-IP Local Traffic Manager

CONFIGURING BIG-IP LOCAL TRAFFIC MANAGER 3-Day

MAGENTO HOSTING Progressive Server Performance Improvements

Prerequisites. Creating Profiles

Citrix NetScaler 10 Essentials and Networking

Exploring Oracle E-Business Suite Load Balancing Options. Venkat Perumal IT Convergence

Load Balancing Microsoft Remote Desktop Services. Deployment Guide

McAfee Web Filter Deployment Guide

Routing Security Server failure detection and recovery Protocol support Redundancy

WEBAPP PATTERN FOR APACHE TOMCAT - USER GUIDE

vrealize Automation Load Balancing

Measurement of the Achieved Performance Levels of the WEB Applications With Distributed Relational Database

Penetration Testing LAB Setup Guide

Copyright Exceliance

Load Balancing for Microsoft Office Communication Server 2007 Release 2

Oracle WebLogic Server 11g Administration

bbc Adobe LiveCycle Data Services Using the F5 BIG-IP LTM Introduction APPLIES TO CONTENTS

CHAPTER 1 - JAVA EE OVERVIEW FOR ADMINISTRATORS

PES. High Availability Load Balancing in the Agile Infrastructure. Platform & Engineering Services. HEPiX Bologna, April 2013

VERITAS Cluster Server Traffic Director Option. Product Overview

Citrix NetScaler 10.5 Essentials for ACE Migration CNS208; 5 Days, Instructor-led

Jive and High-Availability

1. First thing you'll do is login to the New Control Panel, select Load Balancers from the list at the top, and then select Create Load Balancer.

Apache Tomcat. Load-balancing and Clustering. Mark Thomas, 20 November Pivotal Software, Inc. All rights reserved.

OpenFlow Based Load Balancing

Quantum StorNext. Product Brief: Distributed LAN Client

Transcription:

Load balancing MySQL with HaProxy Peter Boros Consultant @ Percona 4/23/13 Santa Clara, CA

Agenda What is HaProxy HaProxy configuration Load balancing topologies Checks Load balancing Percona XtraDB Cluster Load balancing master-slave Cluster managed by PRM Load balancing MySQL Cluster Writing custom checks, large scale issues

What is HaProxy http://haproxy.1wt.eu General purpose load balancer We are using it at the TCP level It doesn't understand the mysql wire protocol It can check backend state on HTTP Current stable version is 1.4 Single process, event-driven

HaProxy configuration Global Logging, user, group,... Defaults Mode, maxconn, timeouts,... Frontend definitions Port, default backed... Backend definitions Backend servers, check method, check interval... Listen Frontend + backend

HaProxy configuration II. Global Defaults global log 127.0.0.1 local0 maxconn 4096 chroot /usr/share/haproxy user haproxy group haproxy daemon option redispatch maxconn 2000 contimeout 5000 clitimeout 50000 srvtimeout 50000

HaProxy configuration III. Frontend frontend stats-front bind *:80 mode http default_backend stats-back Backend mode http balance roundrobin stats uri /haproxy/stats stats auth pxcstats:secret

Deployment scenarios

Separate layer 2xRTT in application response time Scaling: new load balancer pairs for new application servers On MySQL, it will look like every connection is coming from the load balancers

On the application No additional latency Load balancing layer scales with application layer A lot of checks will happen on the databases (each loadbalancer does it's own checks) Connections from application servers

On the database No additional latency The load balancer consumer resources on the database server VIP management is still needed The databases will see that the connections are coming from the local IP

HaProxy performance Session rate Determines if the load balancer can distribute all requests it receives Session concurrency Related to the session rate, the slower the server, the higher the concurrency Data rate Measured in MB/s, highest throughput comes with large sessions

Status page sample

Checks server c1 10.116.39.76:3306 check port 9200 inter 1500 rise 3 fall 3 TCP port 9200 is checked on HTTP Response code 200 -> backend up Response code 500 -> backend down We need something which turns database state into HTTP response codes

Checks II. Clustercheck supplied with PXC Shell script ran through xinetd Simple and maintainable, 1 check can mean several forks With many application servers Daemon, which caches results for the check period Using non-blocking IO

Load balancing PXC PXC architecture N (typically 3) active nodes Writes and reads can go to all nodes Checks dependent on wsrep variables server c1 10.116.39.76:3306 check port 9200 inter 1500 rise 3 fall 3 server c2 10.195.206.117:3306 check port 9200 inter 1500 rise 3 fall 3 backup server c3 10.202.23.92:3306 check port 9200 inter 1500 rise 3 fall 3 backup

Load balancing PRM PRM architecture One master, n slave Separate backend definition for the master and slave Check for read_only=0 flag for master Check if the node is managed by pacemaker

Load balancing MySQL Cluster MySQL Cluster architecture All mysql servers are active One backend definition containing all the servers Check: if mysql is up and ndbcluster is registered as a storage engine, server is up

Performance vs Parallelism From: mysqlperformanceblog.com

Additional Features Queueing maxqueue >> maxconn Only maxconn TCP connections can be there The rest of the connections will be queued on TCP/IP level Ramp-up (slowstart Xs) A server is not getting the full traffic when it comes online The server's weight is adjusted dynamically

Persistent connections HaProxy decides where the connection will go at TCP handshake Once the TCP session is established sessions will stay where they are Be cautious with persistent connections Configuring connection pool properly Important parameters are minimum, maximum connections and connection lifetime

High traffic issues Show themselves later if haproxy is deployed on each application server. Not specific to haproxy Limitations in MySQL client-server protocol Linux TCP/IP implementation http://blog.exceliance.fr/2012/12/12/haproxy-high-mysql-requestrate-and-tcp-source-port-exhaustion/

MySQL client-server communication This means that the connection at the TCP level can be in TIME_WAIT state in minutes Leads to souce ip:port paris exhaustion

Possible solutions Using more than one IP address Tune max local port range /proc/sys/net/ipv4/ip_local_port_range Tune allow tw_recycle, tw_reuse /proc/sys/net/ipv4/tcp_tw_recycle /proc/sys/net/ipv4/tcp_tw_reuse Allow the kernel to kill the connections /proc/sys/net/ipv4/tcp_max_tw_buckets This is very high by default

Possible solutions II. Haproxy's nolinger option Needs 1.4 Connections in TIME_WAIT and FIN_WAIT1 Nolinger patch for glb by Frederic Descamps Using SO_LINGER in setsockopt() helps if this happens at the proxy level But not if a real client is connecting and disconnecting to MySQL too fast

Server closing TCP connection If the server closed the connection, the issue would not be there.

Q&A

Thanks for attention.