Chapter 16 High Availability and Scalability

Table of Contents

16.1 Oracle VM Template for MySQL Enterprise Edition
16.2 Overview of MySQL with DRBD/Pacemaker/Corosync/Oracle Linux
16.3 Overview of MySQL with Windows Failover Clustering
16.4 Using MySQL within an Amazon EC2 Instance
16.4.1 Setting Up MySQL on an EC2 AMI
16.4.2 EC2 Instance Limitations
16.4.3 Deploying a MySQL Database Using EC2
16.5 Using ZFS Replication
16.5.1 Using ZFS for File System Replication
16.5.2 Configuring MySQL for ZFS Replication
16.5.3 Handling MySQL Recovery with ZFS
16.6 Using MySQL with memcached
16.6.1 Installing memcached
16.6.2 Using memcached
16.6.3 Developing a memcached Application
16.6.4 Getting memcached Statistics
16.6.5 memcached FAQ
16.7 MySQL Proxy
16.7.1 MySQL Proxy Supported Platforms
16.7.2 Installing MySQL Proxy
16.7.3 MySQL Proxy Command Options
16.7.4 MySQL Proxy Scripting
16.7.5 Using MySQL Proxy
16.7.6 MySQL Proxy FAQ

Data is the currency of today's web, mobile, social, enterprise and cloud applications. Ensuring data is always available is a top priority for any organization. Minutes of downtime can result in significant loss of revenue and reputation.

There is no one size fits all approach to delivering High Availability (HA). Unique application attributes, business requirements, operational capabilities and legacy infrastructure can all influence HA technology selection. And technology is only one element in delivering HA: people and processes are just as critical as the technology itself.

MySQL is deployed into many applications demanding availability and scalability. Availability refers to the ability to cope with, and if necessary recover from, failures on the host, including failures of MySQL, the operating system, or the hardware and maintenance activity that may otherwise cause downtime. Scalability refers to the ability to spread both the database and the load of your application queries across multiple MySQL servers.

Because each application has different operational and availability requirements, MySQL offers a range of certified and supported solutions, delivering the appropriate levels of High Availability (HA) and scalability to meet service level requirements. Such solutions extend from replication, through virtualization and geographically redundant, multi-data center solutions delivering 99.999% uptime.

Selecting the right high availability solution for an application largely depends on:

The primary solutions supported by MySQL include:

Further options are available using third-party solutions.

Each architecture used to achieve highly available database services is differentiated by the levels of uptime it offers. These architectures can be grouped into three main categories:

As illustrated in the following figure, each of these architectures offers progressively higher levels of uptime, which must be balanced against potentially greater levels of cost and complexity that each can incur. Simply deploying a high availability architecture is not a guarantee of actually delivering HA. In fact, a poorly implemented and maintained shared-nothing cluster could easily deliver lower levels of availability than a simple data replication solution.

Figure 16.1 Tradeoffs: Cost and Complexity versus Availability

As the number of “nines” in the uptime percentage increases, so does the cost and complexity, progressing from basic replication, to a clustered and virtualized configuration, to shared-nothing clusters replicated across geographic regions. Different kinds of organizations require different “nines” of availability, from Internet service providers and mainstream businesses at 3 nines, online services at 4 nines, and eCommerce, telecom, and military applications at 5 nines.

The following table compares the HA and Scalability capabilities of the various MySQL solutions:

Table 16.1 Feature Comparison of MySQL HA Solutions

RequirementMySQL ReplicationDRBDOracle VM TemplateMySQL Cluster
Availability    
Platform SupportAll Supported by MySQL Server (http://www.mysql.com/support/supportedplatforms/database.html)LinuxOracle LinuxAll Supported by MySQL Cluster (http://www.mysql.com/support/supportedplatforms/cluster.html)
Automated IP FailoverNoYesYesDepends on Connector and Configuration
Automated Database FailoverNoYesYesYes
Automatic Data ResynchronizationNoYesN/A - Shared StorageYes
Typical Failover TimeUser / Script DependentConfiguration Dependent, 60 seconds and AboveConfiguration Dependent, 60 seconds and Above1 Second and Less
Synchronous ReplicationNo, Asynchronous and SemisynchronousYesN/A - Shared StorageYes
Shared StorageNo, DistributedNo, DistributedYesNo, Distributed
Geographic redundancy supportYesYes, via MySQL ReplicationYes, via MySQL ReplicationYes, via MySQL Replication
Update Schema On-LineNoNoNoYes
Scalability    
Number of NodesOne Master, Multiple SlavesOne Active (primary), one Passive (secondary) NodeOne Active (primary), one Passive (secondary) Node255
Built-in Load BalancingReads, via MySQL ReplicationReads, via MySQL ReplicationReads, via MySQL Replication & During FailoverYes, Reads and Writes
Supports Read-Intensive WorkloadsYesYesYesYes
Supports Write-Intensive WorkloadsYes, via Application-Level ShardingYes, via Application-Level Sharding to Multiple Active/Passive PairsYes, via Application-Level Sharding to Multiple Active/Passive PairsYes, via Auto-Sharding
Scale On-Line (add nodes, repartition, etc.)NoNoNoYes