Sunday, March 22, 2015

HAproxy Load balancing – part 1 - sheduling algorithms, persistence



This is the first post of haproxy load balancing tutorial series,
Hope to cover below topics and areas of load balancing,


  • ·         What is load balancing and why we need load balancing?
  • ·         Difference between load balancing and high availability
  • ·         What is HAproxy load balancer and related concepts?
  • ·         How to Configure HAproxy in CentOS/RHEL/Fedora to load balance one backend wso2?
  • ·         What is layer 7 load balancing and how to configure HAproxy to load balance layer 7 applications (more than one backends)?
  • ·         Change load balancing algorithm with session persistence.
  • ·         How to test load balancer using curl?
  • ·         Add ssl to HAproxy load balancer?

Hope you will gain lots of knowledge from this tutorial series. Keep in touch…
After this series I will explain how httpd (mod_cluster) load balancing works and full configurations…

What is load balancing and why we need load balancing and related concepts?


There are many definitions in term, Load Balancing. Below is what Wikipedia says about load balancing.
In computing, load balancing distributes workloads across multiple computing resources, such as computers, a computer cluster, network links, central processing units or disk drives. Load balancing aims to optimize resource use, maximize throughput, minimize response time, and avoid overload of any single resource. Using multiple components with load balancing instead of a single component may increase reliability through redundancy. Load balancing usually involves dedicated software or hardware, such as a multilayer switch or a Domain Name System server process.

One of the most commonly used applications of load balancing is to provide a single Internet service from multiple servers, sometimes known as a server farm. Commonly load-balanced systems include popular web sites, large Internet Relay Chat networks, high-bandwidth File Transfer Protocol sites, Network News Transfer Protocol (NNTP) servers, Domain Name System (DNS) servers, and databases.
For Internet services, the load balancer is usually a software program that is listening on the port where external clients connect to access services. The load balancer forwards requests to one of the "backend" servers, which usually replies to the load balancer. This allows the load balancer to reply to the client without the client ever knowing about the internal separation of functions. It also prevents clients from contacting back-end servers directly, which may have security benefits by hiding the structure of the internal network and preventing attacks on the kernel's network stack or unrelated services running on other ports.
Some load balancers provide a mechanism for doing something special in the event that all backend servers are unavailable. This might include forwarding to a backup load balancer, or displaying a message regarding the outage. Load balancing gives the IT team a chance to achieve a significantly higher fault tolerance. It can automatically provide the amount of capacity needed to respond to any increase or decrease of application traffic.
It is also important that the load balancer itself does not become a single point of failure. Usually load balancers are implemented in high-availability pairs which may also replicate session persistence data if required by the specific application

Scheduling algorithms


Numerous scheduling algorithms are used by load balancers to determine which back-end server to send a request to. Simple algorithms include random choice or round robin. More sophisticated load balancers may take additional factors into account, such as a server's reported load, least response times, up/down status (determined by a monitoring poll of some kind), number of active connections, geographic location, capabilities, or how much traffic it has recently been assigned.

Persistence


An important issue when operating a load-balanced service is how to handle information that must be kept across the multiple requests in a user's session. If this information is stored locally on one backend server, then subsequent requests going to different backend servers would not be able to find it. This might be cached information that can be recomputed, in which case load-balancing a request to a different backend server just introduces a performance issue.

No comments:

Post a Comment