{"id":483336,"date":"2022-08-11T09:02:06","date_gmt":"2022-08-11T06:02:06","guid":{"rendered":"https:\/\/en.buradabiliyorum.com\/what-are-load-balancers-how-to-effectively-distribute-incoming-traffic\/"},"modified":"2022-08-11T09:02:06","modified_gmt":"2022-08-11T06:02:06","slug":"what-are-load-balancers-how-to-effectively-distribute-incoming-traffic","status":"publish","type":"post","link":"https:\/\/buradabiliyorum.com\/en\/what-are-load-balancers-how-to-effectively-distribute-incoming-traffic\/","title":{"rendered":"#What Are Load Balancers? How to Effectively Distribute Incoming Traffic"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_85 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a3db43a8520b\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #dd3333;color:#dd3333\" 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: #dd3333;color:#dd3333\" 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><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a3db43a8520b\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-1'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/buradabiliyorum.com\/en\/what-are-load-balancers-how-to-effectively-distribute-incoming-traffic\/#%E2%80%9CWhat_Are_Load_Balancers_How_to_Effectively_Distribute_Incoming_Traffic%E2%80%9D\" >&#8220;What Are Load Balancers? How to Effectively Distribute Incoming Traffic&#8221;<\/a><ul class='ez-toc-list-level-2' ><li class='ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/buradabiliyorum.com\/en\/what-are-load-balancers-how-to-effectively-distribute-incoming-traffic\/#What_Load_Balancers_Do\" >What Load Balancers Do<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/buradabiliyorum.com\/en\/what-are-load-balancers-how-to-effectively-distribute-incoming-traffic\/#Load_Balancing_Algorithms\" >Load Balancing Algorithms<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/buradabiliyorum.com\/en\/what-are-load-balancers-how-to-effectively-distribute-incoming-traffic\/#Other_Load_Balancer_Characteristics\" >Other Load Balancer Characteristics<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/buradabiliyorum.com\/en\/what-are-load-balancers-how-to-effectively-distribute-incoming-traffic\/#Layer_4_and_Layer_7_Load_Balancers\" >Layer 4 and Layer 7 Load Balancers<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/buradabiliyorum.com\/en\/what-are-load-balancers-how-to-effectively-distribute-incoming-traffic\/#Conclusion\" >Conclusion<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h1><span class=\"ez-toc-section\" id=\"%E2%80%9CWhat_Are_Load_Balancers_How_to_Effectively_Distribute_Incoming_Traffic%E2%80%9D\"><\/span>&#8220;What Are Load Balancers? How to Effectively Distribute Incoming Traffic&#8221;<span class=\"ez-toc-section-end\"><\/span><\/h1>\n<div>\n<img loading=\"lazy\" decoding=\"async\" class=\"type:primaryImage alignnone size-full wp-image-811688\" data-pagespeed-no-defer=\"\" src=\"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2022\/06\/shutterstock_295053809.jpg?width=1198&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Photo of fiber networking cables connected to a server\" width=\"1200\" height=\"675\"\/><\/p>\n<p>Load balancers are infrastructure components which distribute incoming network traffic between multiple backend servers. They improve capacity and add redundancy by keeping services accessible if one of your servers fails.<\/p>\n<p>Load balancers act as the public gateway to your <a href=\"https:\/\/buradabiliyorum.com\/en\/category\/download-scripts-themes-apps\/\" data-internallinksmanager029f6b8e52c=\"9\" title=\"Download Scripts &amp; Themes &amp; Apps\" target=\"_blank\" rel=\"noopener\">app<\/a>lication. They\u2019re specialized in their role so they can be highly optimized to maximize traffic throughput. Load balancers are usually configurable with several kinds of routing algorithm to match your application\u2019s requirements.<\/p>\n<p>In this article we\u2019ll explore what load balancers are, how they work, and some of the complications they can cause. We\u2019ll also explain the differences between the most common load balancing algorithms.<\/p>\n<h2 id=\"what-load-balancers-do\"><span class=\"ez-toc-section\" id=\"What_Load_Balancers_Do\"><\/span>What Load Balancers Do<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Load balancers are responsible for providing a reverse proxy in front of your application\u2019s servers. All clients connect to this single proxy instead of the individual backend instances. The load balancer is responsible for selecting a server to handle each request. This occurs invisibly to the external client.<\/p>\n<p>Both hardware- and software-based load balancer implementations are available. On the software side, most web servers such as <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/httpd.apache.org\/docs\/2.4\/mod\/mod_proxy_balancer.html\">Apache<\/a> and <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/docs.nginx.com\/nginx\/admin-guide\/load-balancer\/http-load-balancer\">NGINX<\/a> are capable of fulfilling the role. Hardware-type load balancers are deployed as standalone infrastructure components from your hosting provider.<\/p>\n<p>Load balancers usually monitor the health of instances in their backend server pool. Backends that become unhealthy stop being sent new traffic, reducing service flakiness and downtime. Similarly, load balancers <a href=\"https:\/\/buradabiliyorum.com\/en\/category\/general\/\" data-internallinksmanager029f6b8e52c=\"3\" title=\"General\" target=\"_blank\" rel=\"noopener\">general<\/a>ly let you add new backend instances at any time, so you can scale your service with extra capacity during peak hours.<\/p>\n<p>The primary objective of a load balancer is to maximize throughput and make the most efficient use of available resources. Being able to scale horizontally across physical servers is usually more effective than vertically growing a single node with extra CPU or memory. Horizontal scaling gives you more redundancy as well as capacity while the overhead incurred by the load balancer layer is generally nominal.<\/p>\n<h2 id=\"load-balancing-algorithms\"><span class=\"ez-toc-section\" id=\"Load_Balancing_Algorithms\"><\/span>Load Balancing Algorithms<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Although the aim of load balancing is always to distribute traffic between multiple servers, there are several ways in which this can be achieved. Before looking at specific strategies, it\u2019s important to identify the two fundamental types of algorithm you can select:<\/p>\n<ul>\n<li><strong>Static balancing<\/strong> \u2013 These methods work from hardcoded config values making them completely predictable in their operation. This kind of algorithm doesn\u2019t take into account the state of the backend servers it can forward to, so it could keep sending new requests to an already congested instance.<\/li>\n<li><strong>Dynamic balancing<\/strong> \u2013 Dynamic algorithms tune themselves in real-time based on traffic flow and the availability of servers in your pool. These strategies are able to automatically avoid instances that are already handling several requests. Dynamic load balancing can marginally increase overheads as the load balancer has to track each request\u2019s completion status.<\/li>\n<\/ul>\n<p>Static balancing systems are usually easier to configure, test, and inspect. Dynamic balancing is much more powerful and is usually the preferred choice for production applications. Within each of these classes, there are several specific routing strategies you can choose:<\/p>\n<ul>\n<li><strong>Round robin<\/strong> \u2013 Round robin is a static balancing method that directs requests to each server in turn. If you\u2019ve got three servers A, B, and C, the first incoming request will go to A, the second one to B, and the third to C. The load balancer will start again at A for the fourth request.<\/li>\n<li><strong>Weighted round robin<\/strong> \u2013 A variation of the round robin algorithm where admins define the relative priorities of each server in the pool. A heavily weighted server will be used more frequently, receiving a higher share of the traffic. This method lets you use the round robin strategy when your server pool comprises servers with unequal specifications.<\/li>\n<li><strong>Random<\/strong> \u2013 Many load balancers include a true random option as an alternative static choice.<\/li>\n<li><strong>Hashed<\/strong> \u2013 This static balancing strategy hashes the client\u2019s IP address to determine which of the backend servers will handle the request. This ensures the same instance serves every connection that originates from that client.<\/li>\n<li><strong>Fewest connections<\/strong> \u2013 This is a popular dynamic algorithm that always directs incoming requests to the server with the least number of open connections. In many applications this the most effective way to maximize overall performance.<\/li>\n<li><strong>Highest bandwidth availability<\/strong> \u2013 This method sends new traffic to the server with the most available bandwidth. This is ideal in situations where individual requests are likely to use large amounts of bandwidth even if the total request count remains low.<\/li>\n<li><strong>Custom health\/load endpoint<\/strong> \u2013 Many load balancers include a way to make traffic distribution decisions based on custom metrics exposed by your backend servers. Queries could be made against CPU usage, memory consumption, and other critical measures using a mechanism such as <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/en.wikipedia.org\/wiki\/Simple_Network_Management_Protocol\">SNMP<\/a>.<\/li>\n<\/ul>\n<h2 id=\"other-load-balancer-characteristics\"><span class=\"ez-toc-section\" id=\"Other_Load_Balancer_Characteristics\"><\/span>Other Load Balancer Characteristics<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Load balancers can create a few complications for your application. One of the most prevalent is the challenge of achieving sticky backend sessions. It\u2019s common for systems to maintain state on the server and need to persist it between client connections.<\/p>\n<p>You can mitigate this using the hashed balancing algorithm or a similar client-based option. This guarantees that connections from the same IP address terminate at a particular server. Most load balancers also offer an explicit sticky sessions option that looks for a nominated header or cookie in an HTTP request. This value can be used to consistently direct requests to the same server after the client\u2019s initial connection.<\/p>\n<p>Load balancers can create complexity around SSL too. Many organizations configure SSL to terminate at the load balancer. Connections between the load balancer and your backend servers are made over regular HTTP. This usually results in a simpler set up experience with reduced maintenance demands.<\/p>\n<p>Using HTTP-only connections in the forward direction isn\u2019t always acceptable for security-critical workloads. Load balancers capable of performing SSL passthrough can deliver traffic straight to your backend servers, without decrypting the data first. However this restricts the routing functionality you can use: as the load balancer can\u2019t decrypt incoming requests, you won\u2019t be able to perform matching based on attributes like headers and cookies.<\/p>\n<h2 id=\"layer-4-and-layer-7-load-balancers\"><span class=\"ez-toc-section\" id=\"Layer_4_and_Layer_7_Load_Balancers\"><\/span>Layer 4 and Layer 7 Load Balancers<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Load balancing is often discussed in the context of <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/www.networkworld.com\/article\/3239677\/the-osi-model-explained-and-how-to-easily-remember-its-7-layers.html\">Layer 4 (L4) and Layer 7 (L7)<\/a> networking. These terms describes the point at which the load balancer routes traffic within the lifecycle of a network request.<\/p>\n<p>A Layer 4 resource operates at the network transport level. These load balancers make routing decisions based on characteristics of the request\u2019s transport, such as the TCP or UDP port that was used. Request-specific data isn\u2019t considered.<\/p>\n<p>A Layer 7 load balancer is located adjacent to the application layer. These load balancers can access complex data within the request and use it to inform workload-specific routing rules. This is where load balancing that accounts for a session ID in a HTTP header or cookie can take place.<\/p>\n<p>Layer 7 load balancing is powerful but relatively resource intensive. It needs to parse and inspect the content of each request before it can be passed to a backend. The packet-based nature of Layer 4 load balancers provides less control but has a correspondingly reduced impact on throughput. Layer 4 doesn\u2019t decrypt traffic either so a load balancer compromise at this stage won\u2019t expose request data.<\/p>\n<h2 id=\"conclusion\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Load balancers let you route incoming traffic between your servers. They\u2019re a critical component of highly available networking architectures that let you transparently run multiple backend instances. This increases service capacity and avoids a total outage if one server goes offline.<\/p>\n<p>Most load balancer implementations give you the choice of several different algorithms, including both static and dynamic options. Many applications are well served by simple choices such as \u201cfewest connections\u201d or \u201cround robin\u201d but more complex options are useful in specific situations.<\/p>\n<p>It\u2019s good practice to run every production application behind a load balancer. It gives you flexibility to scale on-demand and react to unhealthy servers. Load balancing is usually easy to set up within your hosting stack or cloud provider\u2019s networking infrastructure.<\/p>\n<\/div>\n<p><script>\n setTimeout(function(){\n  !function(f,b,e,v,n,t,s)\n  {if(f.fbq)return;n=f.fbq=function(){n.callMethod?\n  n.callMethod.apply(n,arguments):n.queue.push(arguments)};\n  if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';\n  n.queue=[];t=b.createElement(e);t.async=!0;\n  t.src=v;s=b.getElementsByTagName(e)[0];\n  s.parentNode.insertBefore(t,s) } (window, document,'script',\n  'https:\/\/connect.facebook.net\/en_US\/fbevents.js');\n   fbq('init', '335401813750447');\n   fbq('track', 'PageView');\n  },3000);\n<\/script><\/p>\n<blockquote><p><strong><span style=\"color: #ff6600;\">If you liked the article, do not forget to share it with your friends. Follow us on\u00a0<span style=\"color: #ff0000;\"><a style=\"color: #ff0000;\" href=\"https:\/\/news.google.com\/publications\/CAAqBwgKMLG0nwswvr63Aw\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Google News<\/a><\/span>\u00a0too, click on the star and choose us from your favorites.<\/span><\/strong><\/p><\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\">For forums sites go to <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/forum.buradabiliyorum.com\/\" target=\"_blank\" rel=\"noopener\">Forum.BuradaBiliyorum.Com<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\"><strong>If you want to read more like this article, you can visit our <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/en.buradabiliyorum.com\/technology\/\" target=\"_blank\" rel=\"noopener\">Technology category.<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<p><span style=\"color: black;\"><a style=\"color: #ff9900;\" href=\"https:\/\/www.howtogeek.com\/devops\/what-are-load-balancers-how-to-effectively-distribute-incoming-traffic\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;What Are Load Balancers? How to Effectively Distribute Incoming Traffic&#8221; Load balancers are infrastructure components which distribute incoming network traffic between multiple backend servers. They improve capacity and add redundancy by keeping services accessible if one of your servers fails. Load balancers act as the public gateway to your application. They\u2019re specialized in their role&#8230;<\/p>\n","protected":false},"author":1,"featured_media":483337,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"https:\/\/www.howtogeek.com\/wp-content\/uploads\/2022\/06\/shutterstock_295053809.jpg?height=200p&trim=2,2,2,2","fifu_image_alt":"","footnotes":""},"categories":[18],"tags":[],"class_list":["post-483336","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/483336","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/comments?post=483336"}],"version-history":[{"count":0,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/483336\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media\/483337"}],"wp:attachment":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media?parent=483336"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/categories?post=483336"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/tags?post=483336"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}