6 Jul 2013

AWS Load Balancing for the Percona XtraDB Cluster

Database uptime and resilience is crucial for cloud infrastructure and in this post I'm going to detail a simple but powerful load balanced Percona XtraDB Cluster utilising components from Amazon Web Services.
Percona XtraDB Cluster integrates Percona Server with the Galera library of MySQL high availability solutions while AWS delivers a set of services that together form a reliable, scalable, and inexpensive cloud computing platform. Combining both technologies delivers an incredibily robust cloud DB solution.

Let's take a look at the basic schematic. For those familiar with AWS infrastructure design the components will be familiar. For those new to AWS a breakdown of services used with explanations of function and reasons for selection along with expanded design options follows.

Cluster

The Percona XtraDB cluster itself (PXC) is a default installation. AWS components used are :
  • M1.large (or above) EC2 instances (virtual servers) running optimised IOPS Elastic Block Store (EBS) volumes. Enhanced IOPS for EBS guarantees selected I/O and is recommended for high performance databases.
  • Multi-AZ (availability zone) placement. AWS AZ's in a region are independently isolated, but connected through low-latency links. Distributing instances across AZ's facilitates redundancy should a single zone become unavailable for any reason.
  • The Percona DB instances are contained within a private AWS Virtual Private Cloud (VPC) and run inside a dedicated security group (SG). The SG is fully configurable for secure port and protocol lockdown between all instances and other AWS components (i.e the Elastic Load Balancer). A private VPC and default security group are not accessible from the public internet.
  • In this basic configuration we are balancing the PXC with an AWS Elastic Load Blancer configured for DB related port listeners (i.e 3306 + a related health check). Due to the nature of backend PXC technology there is no need to configure sticky sessions (ELB sticky sessions are more appicable to balanced application roles). An ELB balanced PXC functions perfectly well although the ELB does not take into an account state of the node other that it being present (although you could set the health check on the service .pid), as such it could be sending queries to a node that has mysqld running even if it’s in “JOINING” or “DISCONNECTED” state. A basic HAProxy balancing client would function in exactly the same manner although could be configured for more granular node checks. To implement HAProxy into this design would merely involve adding another VPC container for load balanced HAProxy roles inbetween the Application and PXC VPCs.

Application

In this design we are using self contained static application roles built on Ubuntu server.
  • A static role configuration contains no dynamic data, i.e all dynamic data is DB side. Should a dynamic data proviso be required at app level (i.e for uploaded client assetts etc) a linked AWS S3 storage component is recomended. S3 is straightforward to implement and opens up options for AWS Cloudfront CDN integration. AWS Cloudfront is a global web service for content delivery offering low latency, high data transfer speeds and enhanced distribution.
  • The balanced app roles as specified could easily be replaced as a load responsive scaling group. Depending on load and type of instances used this could deliver effective cost reductions along with increased resilience.
  • As with the PXC all instances run in their own SG and VPC. The VPC in this instance is public facing with Elastic (static) IPs, although as AWS Route 53 DNS caters for direct ELB connectivity this configuration is optional and it should be noted that a private VPC is inherently more secure.
If you are interested in running an AWS PXC as detailed here, or if you have any other questions or requirements around AWS, Database or Cloud Technology in general, Cirronix would be more than happy to hook up and discuss your needs.
We are an established UK based cloud consultancy with a global client base offering a comprehensive range of virtual infrastructure development & support services. We are both an AWS and Scalr consulting partner as well as holding AWS Professional accreditation.

Please visit our website at http://cirronix.com for contact details along with more information on our comprehensive range of services.

In the next post we'll look at ELB Failover for our AWS hosted Percona XtraDB Cluster.

No comments:

Post a Comment