{"id":7452,"date":"2016-07-04T12:58:41","date_gmt":"2016-07-04T12:58:41","guid":{"rendered":"http:\/\/www.esds.co.in\/blog\/?p=7452"},"modified":"2019-01-25T09:03:44","modified_gmt":"2019-01-25T09:03:44","slug":"types-of-load-balancing","status":"publish","type":"post","link":"https:\/\/www.esds.co.in\/blog\/types-of-load-balancing\/","title":{"rendered":"Types of Load Balancing"},"content":{"rendered":"<p><a href=\"https:\/\/www.esds.co.in\/blog\/wp-content\/uploads\/2016\/07\/Types-of-Load-Balancing.gif\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-7453 size-full\" src=\"https:\/\/www.esds.co.in\/blog\/wp-content\/uploads\/2016\/07\/Types-of-Load-Balancing.gif\" alt=\"Types-of-Load-Balancing\" width=\"674\" height=\"319\" \/><\/a><\/p><div id=\"ez-toc-container\" class=\"ez-toc-v2_0_76 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.esds.co.in\/blog\/types-of-load-balancing\/#Load_Balancing\" >Load Balancing\u00a0<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.esds.co.in\/blog\/types-of-load-balancing\/#No_Load_Balancing\" >No Load Balancing<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.esds.co.in\/blog\/types-of-load-balancing\/#Layer_4_Load_Balancing\" >Layer 4 Load Balancing<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.esds.co.in\/blog\/types-of-load-balancing\/#Layer_7_Load_Balancing\" >Layer 7 Load Balancing<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.esds.co.in\/blog\/types-of-load-balancing\/#Sticky_Sessions\" >Sticky Sessions<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.esds.co.in\/blog\/types-of-load-balancing\/#Health_Check\" >Health Check<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.esds.co.in\/blog\/types-of-load-balancing\/#High_Availability\" >High Availability<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.esds.co.in\/blog\/types-of-load-balancing\/#Conclusion\" >Conclusion<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n\n<h2><span class=\"ez-toc-section\" id=\"Load_Balancing\"><\/span><strong>Load Balancing\u00a0<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>In a previous article we have seen the basic mechanisms that are used while configuring load balancing <strong>(<a href=\"https:\/\/www.esds.co.in\/blog\/how-load-balancing-works\/\">Load Balancing with HAProxy for High-Availability<\/a>)<\/strong>, so let\u2019s get into the types of load balancing\u2026<\/p>\n<h3><span class=\"ez-toc-section\" id=\"No_Load_Balancing\"><\/span><strong>No Load Balancing<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>The name says it all; without load balancing it&#8217;s just a simple web application environment. The following diagram will help you to understand it in a right way:<\/p>\n<p><a href=\"https:\/\/www.esds.co.in\/blog\/wp-content\/uploads\/2016\/07\/No-Load-Balancing.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-7456 aligncenter\" src=\"https:\/\/www.esds.co.in\/blog\/wp-content\/uploads\/2016\/07\/No-Load-Balancing.png\" alt=\"No Load Balancing\" width=\"674\" height=\"331\" srcset=\"https:\/\/www.esds.co.in\/blog\/wp-content\/uploads\/2016\/07\/No-Load-Balancing.png 674w, https:\/\/www.esds.co.in\/blog\/wp-content\/uploads\/2016\/07\/No-Load-Balancing-150x74.png 150w, https:\/\/www.esds.co.in\/blog\/wp-content\/uploads\/2016\/07\/No-Load-Balancing-300x147.png 300w, https:\/\/www.esds.co.in\/blog\/wp-content\/uploads\/2016\/07\/No-Load-Balancing-660x324.png 660w\" sizes=\"auto, (max-width: 674px) 100vw, 674px\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">The above diagram denotes, the user connects straight to the web server i.e. domain.com and there is no presence of load balancing. This mean, in case the web server goes offline due to some reasons; the end user will not be able to access it. In another scenario, if there are multiple users trying to access the web server simultaneously and web server shows its limitation to handle the load, the end users generally experience the slower response or might not able to connect to the server at all.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Layer_4_Load_Balancing\"><\/span><strong>Layer 4 Load Balancing<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">Layer 4 load balancing (which is also called as transport layer load balancing) is widely acknowledged for its simple way to load balance the network traffic through multiple servers. This type is based on IP range\/domain and port i.e. if user request comes in for domain.com\/blog, the traffic will be sent to the backend that manages all the user requests for domain.com on port 80.<\/p>\n<p>Check the below diagram to see a simple example of layer 4 load balancing:<\/p>\n<p><a href=\"https:\/\/www.esds.co.in\/blog\/wp-content\/uploads\/2016\/07\/Layer-4-Load-Balancing.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-7457 aligncenter\" src=\"https:\/\/www.esds.co.in\/blog\/wp-content\/uploads\/2016\/07\/Layer-4-Load-Balancing.png\" alt=\"Layer 4 Load Balancing\" width=\"674\" height=\"331\" srcset=\"https:\/\/www.esds.co.in\/blog\/wp-content\/uploads\/2016\/07\/Layer-4-Load-Balancing.png 674w, https:\/\/www.esds.co.in\/blog\/wp-content\/uploads\/2016\/07\/Layer-4-Load-Balancing-150x74.png 150w, https:\/\/www.esds.co.in\/blog\/wp-content\/uploads\/2016\/07\/Layer-4-Load-Balancing-300x147.png 300w, https:\/\/www.esds.co.in\/blog\/wp-content\/uploads\/2016\/07\/Layer-4-Load-Balancing-660x324.png 660w\" sizes=\"auto, (max-width: 674px) 100vw, 674px\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">In this architecture, the user first connects to the load balancer and then the user request is sent to the web servers. The selected web server responds directly to the user request immediately. Usually, all the web servers contain the similar data which avoid sending back inconsistent content to the user. Remember, all the web servers connect to the similar database server.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Layer_7_Load_Balancing\"><\/span><strong>Layer 7 Load Balancing<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Also known as application layer load balancing is more refined and sophisticated way of network traffic load balancing than Layer 4. This mode is based on the content of the user\u2019s request in which load balancer send user request to the web servers according to the content of a request. This is the very advantageous way because users can run multiple web servers on the same domain and port.<\/p>\n<p>Check the below diagram to see a simple example of layer 7 load balancing:<\/p>\n<p><a href=\"https:\/\/www.esds.co.in\/blog\/wp-content\/uploads\/2016\/07\/Layer-7-Load-Balancing.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-7458 aligncenter\" src=\"https:\/\/www.esds.co.in\/blog\/wp-content\/uploads\/2016\/07\/Layer-7-Load-Balancing.png\" alt=\"Layer 7 Load Balancing\" width=\"674\" height=\"331\" srcset=\"https:\/\/www.esds.co.in\/blog\/wp-content\/uploads\/2016\/07\/Layer-7-Load-Balancing.png 674w, https:\/\/www.esds.co.in\/blog\/wp-content\/uploads\/2016\/07\/Layer-7-Load-Balancing-150x74.png 150w, https:\/\/www.esds.co.in\/blog\/wp-content\/uploads\/2016\/07\/Layer-7-Load-Balancing-300x147.png 300w, https:\/\/www.esds.co.in\/blog\/wp-content\/uploads\/2016\/07\/Layer-7-Load-Balancing-660x324.png 660w\" sizes=\"auto, (max-width: 674px) 100vw, 674px\" \/><\/a><\/p>\n<p><strong>The Frontend configuration example: <\/strong><\/p>\n<pre style=\"font-family: monospace; font-size: 0.99em; width: 99%; height: 5%; border: green 2px solid; color: yellow; background-color: #000000;\">frontend http\r\n  bind *:80\r\n  mode http\r\n\r\n  acl url_blog path_beg \/blog\r\n  use_backend blog-backend if url_blog\r\n\r\n  default_backend web-backend\r\n<\/pre>\n<ol>\n<li>\u201cAcl url_blog path_beg\/blog\u201d meet a request if the path of the user\u2019s request starts with \/blog<\/li>\n<li>\u201cUse_backend blog-backend if url_blog\u201d uses the ACL to proxy the traffic to blog-backend<\/li>\n<li>\u201cDefault_backend web-backend\u201d identifies that all other traffic will be forwarded to web-backend<\/li>\n<\/ol>\n<p><strong>Load Balancing Algorithms<\/strong><\/p>\n<p style=\"text-align: justify;\">The algorithm plays a key role to define which server will take place during load balancing. And HAProxy offers plenty of options for algorithm. Furthermore, servers can be allocated with a <em>weight parameter <\/em>to handle how often the server is chosen as compared to other servers.<\/p>\n<p style=\"text-align: justify;\">HAProxy offers numerous algorithm options, but we will cover a few of them only, as describing all of them will make this post like a Ph.D. thesis :). You should visit <a href=\"http:\/\/cbonte.github.io\/haproxy-dconv\/index.html\">http:\/\/cbonte.github.io\/haproxy-dconv\/index.html<\/a> to see the configuration manual for a complete list of algorithms.<\/p>\n<p><strong>Anyway, let\u2019s see the regularly used algorithms:<\/strong><\/p>\n<ul>\n<li><strong>Algorithms<\/strong>\n<ul>\n<li><strong>Weights parameter<\/strong><\/li>\n<li><strong>Round Robin<\/strong>\n<ul>\n<li>This is the default algorithm that selects the servers in a rotational way.<\/li>\n<\/ul>\n<\/li>\n<li><strong>Leastconn<\/strong>\n<ul>\n<li>Minimum numbers of connections are considered here for the server selection. For longer sessions, this algorithm is highly recommended. In the same way, backend servers turn in a round-robin way.<\/li>\n<\/ul>\n<\/li>\n<li><strong>Source<\/strong>\n<ul>\n<li>The server selection is based on the hash of the source IP address i.e. user\u2019s IP. This makes sure that the user will connect to the matching server.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3><span class=\"ez-toc-section\" id=\"Sticky_Sessions\"><\/span><strong>Sticky Sessions<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">Certain applications demand that a user continues to connect to the similar backend server. This tenacity is accomplished via sticky sessions, using the\u00a0appsession\u00a0parameter in the backend that requires it.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Health_Check\"><\/span><strong>Health Check<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">The health check checks whether backend is vacant to route requests or not, this means there is no manual intervention to remove an unavailable backend. The default health check is to try to launch TCP connection to check the availability of the backend servers.<\/p>\n<p>If in case a server fails a health check, and for that reason, it is unable to respond to the server requests, it is by default gets disabled in the backend. This mean, traffic will not be sent to backend server till it turns out to be healthy again. If we consider the worst situation where all backend servers fail, then the service will become unavailable till at least one of them turns back up again&#8230;<\/p>\n<p style=\"text-align: justify;\">However, the default health check is not enough in some types of backends such as database servers in certain conditions to figure out whether the server is still healthy or not.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"High_Availability\"><\/span><strong>High Availability<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">As mentioned above the layer 4 and layer 7 load balancing works based on the use of a load balancer to direct traffic to one of many backend servers. In both these types \u00a0of load balancers is a single point of failure so if main load balancer goes down due to some reasons or it gets overcrowded with requests, the end user experience the high latency or downtime for the service.<\/p>\n<p style=\"text-align: justify;\">To overcome this issue a high-availability configuration is mostly preferred because it eliminates a single point of failure. By adding redundancy to each layer of your architecture, HA configuration prevents a single server failure point. Basically, load balancer enables redundancy to the backend servers, but to achieve a real high availability there is a need of redundant load balancers as well.<\/p>\n<p>The following diagram will help you to understand a basic high availability setup:<\/p>\n<p><a href=\"https:\/\/www.esds.co.in\/blog\/wp-content\/uploads\/2016\/07\/High-Availability.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-7459 aligncenter\" src=\"https:\/\/www.esds.co.in\/blog\/wp-content\/uploads\/2016\/07\/High-Availability.png\" alt=\"High-Availability\" width=\"674\" height=\"331\" srcset=\"https:\/\/www.esds.co.in\/blog\/wp-content\/uploads\/2016\/07\/High-Availability.png 674w, https:\/\/www.esds.co.in\/blog\/wp-content\/uploads\/2016\/07\/High-Availability-150x74.png 150w, https:\/\/www.esds.co.in\/blog\/wp-content\/uploads\/2016\/07\/High-Availability-300x147.png 300w, https:\/\/www.esds.co.in\/blog\/wp-content\/uploads\/2016\/07\/High-Availability-660x324.png 660w\" sizes=\"auto, (max-width: 674px) 100vw, 674px\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">The above diagram clearly describes the functionality of multiple load balancers. In this diagram, 2 load balancers are in the action; one is active and second is in passive mode (you can add more load balancers in passive mode) behind a static IP address, which can be remapped from one server to another. In this kind of setup, if one load balancer fails, the failover mechanism immediately identify it and automatically reallocate the IP address to one of the servers in passive mode. This is just one of the ways to implement active\/passive high availability setup; however, there are many different techniques.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span><strong>Conclusion<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\">These two articles depict the fundamentals of load balancing and HAProxy, which will help you to understand how to increase the performance and reliability of your crucial server environment. If in case you have any further questions regarding HAProxy and Load Balancing, don\u2019t hesitate to ask them in the comment section.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Load Balancing\u00a0 In a previous article we have seen the basic mechanisms that are used while configuring load balancing (Load Balancing with HAProxy for High-Availability), so let\u2019s get into the types of load balancing\u2026 No Load Balancing The name says it all; without load balancing it&#8217;s just a simple web application environment. The following diagram&#8230; <\/p>\n<div class=\"clear\"><\/div>\n<p><a href=\"https:\/\/www.esds.co.in\/blog\/types-of-load-balancing\/\" class=\"gdlr-button small excerpt-read-more\">Read More<\/a><\/p>\n","protected":false},"author":26,"featured_media":7461,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[1559],"tags":[1472],"class_list":["post-7452","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-leaders-talk","tag-load-balancing-with-haproxy"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.esds.co.in\/blog\/wp-json\/wp\/v2\/posts\/7452","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.esds.co.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.esds.co.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.esds.co.in\/blog\/wp-json\/wp\/v2\/users\/26"}],"replies":[{"embeddable":true,"href":"https:\/\/www.esds.co.in\/blog\/wp-json\/wp\/v2\/comments?post=7452"}],"version-history":[{"count":5,"href":"https:\/\/www.esds.co.in\/blog\/wp-json\/wp\/v2\/posts\/7452\/revisions"}],"predecessor-version":[{"id":8804,"href":"https:\/\/www.esds.co.in\/blog\/wp-json\/wp\/v2\/posts\/7452\/revisions\/8804"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.esds.co.in\/blog\/wp-json\/wp\/v2\/media\/7461"}],"wp:attachment":[{"href":"https:\/\/www.esds.co.in\/blog\/wp-json\/wp\/v2\/media?parent=7452"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.esds.co.in\/blog\/wp-json\/wp\/v2\/categories?post=7452"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.esds.co.in\/blog\/wp-json\/wp\/v2\/tags?post=7452"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}