{"id":2053,"date":"2026-07-22T00:36:53","date_gmt":"2026-07-21T17:36:53","guid":{"rendered":"https:\/\/sumberlaba.com\/index.php\/2026\/07\/22\/how-to-set-up-a-load-balancer-for-high-availability\/"},"modified":"2026-07-22T00:36:53","modified_gmt":"2026-07-21T17:36:53","slug":"how-to-set-up-a-load-balancer-for-high-availability","status":"publish","type":"post","link":"https:\/\/sumberlaba.com\/index.php\/2026\/07\/22\/how-to-set-up-a-load-balancer-for-high-availability\/","title":{"rendered":"How to Set Up a Load Balancer for High Availability"},"content":{"rendered":"<h1>How to Set Up a Load Balancer for High Availability<\/h1>\n<p>Load balancers distribute incoming traffic across multiple servers, preventing any single server from becoming overwhelmed. This ensures high availability, better performance, and fault tolerance. Whether you\u2019re using a hardware appliance or software like Nginx or HAProxy, the core setup follows similar steps.<\/p>\n<p>In this tutorial, we\u2019ll walk through setting up a basic software load balancer using Nginx on Ubuntu. We assume you have at least two backend servers running your application and one dedicated server for the load balancer.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/via.placeholder.com\/800x600\/4a90d9\/ffffff?text=how%20to%20set%20up%20a%20load%20balancer\" alt=\"Article illustration\" style=\"display:block;margin:20px auto;max-width:100%;height:auto;border-radius:8px;\" \/><\/p>\n<h2>1. Install and Configure Nginx<\/h2>\n<p>SSH into your load balancer server and install Nginx:<\/p>\n<pre><code>sudo apt update\nsudo apt install nginx<\/code><\/pre>\n<p>Open the default config file:<\/p>\n<pre><code>sudo nano \/etc\/nginx\/nginx.conf<\/code><\/pre>\n<p>Find the <code>http<\/code> block and add an <code>upstream<\/code> directive listing your backend servers:<\/p>\n<pre><code>upstream backend {\n    server 192.168.1.10:80;\n    server 192.168.1.11:80;\n}<\/code><\/pre>\n<h3>2. Set Up the Server Block<\/h3>\n<p>Inside the same <code>http<\/code> block, configure a <code>server<\/code> block to proxy requests:<\/p>\n<pre><code>server {\n    listen 80;\n    server_name example.com;\n\n    location \/ {\n        proxy_pass http:\/\/backend;\n        proxy_set_header Host $host;\n        proxy_set_header X-Real-IP $remote_addr;\n    }\n}<\/code><\/pre>\n<p>Save the file and test the configuration:<\/p>\n<pre><code>sudo nginx -t\nsudo systemctl restart nginx<\/code><\/pre>\n<h3>3. Enable Load Balancing Methods<\/h3>\n<p>Nginx defaults to round-robin. For session persistence (sticky sessions), add <code>ip_hash<\/code> inside the <code>upstream<\/code> block:<\/p>\n<pre><code>upstream backend {\n    ip_hash;\n    server 192.168.1.10:80;\n    server 192.168.1.11:80;\n}<\/code><\/pre>\n<h3>4. Health Checks and Monitoring<\/h3>\n<p>For basic checks, use passive health monitoring (Nginx marks a server down after a failure). For active checks, consider using HAProxy or a third-party module. You can also monitor logs:<\/p>\n<pre><code>sudo tail -f \/var\/log\/nginx\/access.log<\/code><\/pre>\n<h2>Conclusion<\/h2>\n<p>Setting up a load balancer with Nginx takes only a few minutes. By distributing traffic across multiple servers, you gain reliability and scalability. For production, add SSL termination and fine-tune timeouts. Experiment with different algorithms to find what works best for your application.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to Set Up a Load Balancer for High Availability Load balancers distribute incoming traffic across multiple servers, preventing any single server from becoming overwhelmed. This ensures high availability, better performance, and fault tolerance. Whether you\u2019re using a hardware appliance or software like Nginx or HAProxy, the core setup follows similar steps. In this tutorial, &hellip; <\/p>\n","protected":false},"author":2716,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"footnotes":""},"categories":[],"tags":[],"class_list":["post-2053","post","type-post","status-publish","format-standard","hentry"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/sumberlaba.com\/index.php\/wp-json\/wp\/v2\/posts\/2053","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sumberlaba.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sumberlaba.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sumberlaba.com\/index.php\/wp-json\/wp\/v2\/users\/2716"}],"replies":[{"embeddable":true,"href":"https:\/\/sumberlaba.com\/index.php\/wp-json\/wp\/v2\/comments?post=2053"}],"version-history":[{"count":0,"href":"https:\/\/sumberlaba.com\/index.php\/wp-json\/wp\/v2\/posts\/2053\/revisions"}],"wp:attachment":[{"href":"https:\/\/sumberlaba.com\/index.php\/wp-json\/wp\/v2\/media?parent=2053"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sumberlaba.com\/index.php\/wp-json\/wp\/v2\/categories?post=2053"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sumberlaba.com\/index.php\/wp-json\/wp\/v2\/tags?post=2053"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}