What is Load Balancing?

Load balancing is a set of techniques that configure the servers and other hardware in such a way that the workload is distributed equally amongst the servers, thereby reducing the dependency on any single server and making it easy to add resources in such a way that performance is scaled according to the resources added. A load balancer checks the utilization of all servers in a cluster. The server with the estimated best performance gets the next user request. This algorithm ensures the best performance available at the time is given to the users. A very important consideration here is the quality of the load balancer. In this case, quality means the opportunity of the system to make a highly qualified forecast about which server will offer the best performance concerning an individual application. Another aspect to make the decision is to reconnect the client to an existing session. Without any kind of protection, the load balancer could be a single point of failure. If one server is out of service, then the whole system would still work. The load balancer will recognize the failed node, and mark the crashed system. The total performance of the load balancing server (cluster) will be reduced, but the services would still continue to function.

A high availability clustering, also called a failover clustering, is used to protect one or more business critical applications, 100% uptime websites. High availability cluster solutions which include the opportunity to configure protection for one or more applications are state-of-the-art. With this kind of a solution, the crash of one application doesn't require a restart of the complete node, thereby not interrupting all the other working applications. Depending on the client-side of the application, the last transaction could be lost during a failover.

Basic HTTP Load Balancing

A typical Linux Load Balancing Solution architecture consists of 2 or more similar configuration web servers and database servers which are behind a Load Balancer or Master Server. Each web/database server will have a public IP assigned to it as well as an Internal LAN IP. After the implementation of Load Balancing routing rules on the Load Balancer, we configure Firewall rules to allow web traffic on the web and database servers to pass through the Load Balancer or Master Server. The Load Balancer/Master Server then takes care of equal distribution of traffic on each of the web servers and passes on SQL queries to the database server.

We implement MySQL clustering between the database servers using MySQL Cluster software. MySQL Cluster service is used to provide high-availability, high-redundancy for the distributed computing environment. It is a fault tolerant in-memory clustered database designed for 99.99% availability and fast automatic failover, all running on cost effective commodity hardware.

MySQL Cluster Core Concepts - NDBCLUSTER (also known as NDB) is an in-memory storage engine offering high-availability and data-persistence features. The NDBCLUSTER storage engine can be configured with a range of failover and load-balancing options, but it is easiest to start with the storage engine at the cluster level. MySQL Cluster's NDB storage engine contains a complete set of data, dependent only on other data within the cluster itself.

There are three types of cluster nodes, and in a minimal MySQL Cluster configuration, there will be at least three nodes, one of each of these types :

A) Management node : The role of this type of node is to manage the other nodes within the MySQL Cluster, performing functions such as providing configuration data, start and stop nodes, running backups, and so forth. Because this node type manages the configuration of the other nodes, a node of this type should be started first, before any other node. An MGM node is started with the command ndb_mgmd.

B) Data node : This type of node stores cluster data. There are as many data nodes as there are replicas, times the number of fragments. MySQL Cluster tables are normally stored completely in memory rather than on disk.

C) SQL node : This is a node that accesses the cluster data. In the case of MySQL Cluster, an SQL node is a traditional MySQL server that uses the NDBCLUSTER storage engine. An SQL node is a MySQLd process started with the --ndbcluster and --ndb-connectstring options.

For Apache/Database Load Balancing and Clustering, we use HAProxy, a very fast and reliable solution offering high availability, load balancing, and proxying for TCP and HTTP-based applications which distributes the traffic between the servers. It is particularly suited for web sites crawling under very high loads while needing persistence or Layer7 processing. Supporting tens of thousands of connections is clearly realistic with today's hardware. Its mode of operation makes its integration into existing architectures very easy and risk free, while still offering the possibility not to expose fragile web servers to the Net.

HAProxy is a TCP/HTTP reverse proxy which is particularly suited for high availability environments. It can :

  • Route HTTP requests depending on statically assigned cookies.
  • Spread the load among several servers while assuring server persistence through the use of HTTP cookies.
  • Switch to backup servers in the event a main one fails.
  • Accept connections to special ports dedicated to service monitoring.
  • Stop accepting connections without breaking existing ones.
  • Add/modify/delete HTTP headers both ways.
  • Block requests matching a particular pattern.
  • Hold clients to the right application server depending on application cookies
  • Report detailed status as HTML pages to authenticated users from an URI intercepted from the application.

Being an event-driven architecture, it needs very little resource and allows easy handling of thousands of simultaneous connections on hundreds of instances without risking the system's stability.

HAProxy supports several load-balancing algorithms :

  • Simple round robin (traffic divided equally)
  • Least connections (server with least connections gets the request)
  • And Source (The source IP address is hashed and divided by the total weight of the running servers to designate which server will receive the request)
  • The source algorithm ensures that the same client IP address will always reach the same server as long as no server goes down or up. Very important when using HAProxy to load balance databases and avoid replication latencies.

While every scenario is different, a general configuration for a basic load balancing server setup would look similar to this :

A) Apache/Database Load balancing and Clustering with a Dedicated Cisco ASA Firewall

Load Balancer & MYSQL Cluster Management NODE VM/Server – the Virtual Machine/Server for the load balancer has to be built using the Load Balancer Appliance template. We also install the MySQL cluster management node on the load balancer which keeps database synchronization between the database servers/VMs

Application & Database Server/VM – The two Virtual Machines or Dedicated servers for the application & database should be built using the template and resources that best suit your needs. Additional application Dedicated server or Virtual Machines can be added anytime to the load balancing setup.

Minimum Requirements for Apache/Database Load Balancing and Clustering

A) Minimum 3 Servers and a Firewall

  • 1 x Load Balancer Server
  • 2 x Apache and MySQL Servers – Minimum*
  • 1 x Dedicated Cisco ASA Firewall

*Number of Apache and MySQL Servers can be more than 2 and customized depending upon the requirements.

B) High Availability Load Balancer & Apache, MySQL Clustering Configuration

Overview of Load Balancing and High Availability Setup

High availability runs on top of the load balancer configuration, using a second load balancer server. This provides multiple points of failure, meaning that if the primary load balancer server is unavailable, the secondary load balancer server immediately takes over so that your applications or sites are not down.

High Availability - Basic Configuration

High availability service also known as Failover Clustering uses two servers as load balancers, and at least two servers as application and database servers. Servers in a load balancing and high availability configuration are spread across two or more data centres and multiple racks so that there is no single point of failure.

While every scenario is different, a general configuration for a standard load balancing and high availability setup would look similar to this :

Load Balancer – The two servers for the load balancers have to be built using the Load Balancer Appliance template. It acts as master/slave load balancer. The slave server keeps checking master server heartbeat at all times. If the master server is found to be down, then the load balancer IP address is automatically routed on to the slave server. This process won't incur downtime of even a second. The MySQL Cluster management node is setup on both load balancer servers.

Application & Database Server – Minimum two servers for the application servers should be built using the template and resources that best suit your needs. You can easily add additional application servers to the load balancing setup later when required. We install MySQL on same servers on which web server is running and also configure MySQL cluster service between them.

Minimum Requirements for High Availability Load Balancer & Apache, MySQL Clustering

B) Minimum 4 Servers

  • 2 x Load Balancer Servers For Redundancy
  • 2 x Apache and MySQL Servers For Redundancy – Minimum*

*Number of Apache and MySQL Servers can be more than 2 and customized depending upon the requirements.

In this era of 100% uptime and varying degrees of traffic, the portals that are accessed by thousands of users per day have to be supported by a robust infrastructure. eUKhost provides such high availability infrastructure equipped with load balancers to ensure that all visitors coming to these portals have a seamless and smooth experience. Over the last decade, eUKhost has specialised in setting up high availability load balanced clusters for its clients.

Group of European Lottery & Fundraising Portals

This client owns a group of online portals which associate lottery programmes with online charity and fundraising promotions wherein people get a chance to bid for special time with celebrities. The money generated through this bidding is then utilized for charity purposes. Read more.

Price Comparison Portal

The client is a provider of online price comparison for products and services offered in various European countries. Their portal gives an accurate and latest overview of the offers and pricing of products that the visitor searches. Their website connects with various reputed online shops to collect the pricing data, structure it and then present it to the visitor. Read more.

Online Gaming Solutions Provider

This client of eUKhost is a Gaming solutions provider offering games development & consulting to customers and help them establish their existence in the Gaming World. The growth of this client required a high availability clustered solution with failover. Read more.

eUKhost is rated based on 1326 reviews via Facebook and Google+