Quick Chat: Server Load Balancing and Redundancy with HA Proxy

Quick Chat: Server Load Balancing and Redundancy with HA Proxy

What is HA Proxy?

HA Proxy is a free and open source load balancer and proxy server for tcp and HTTP based applications that allows for spread requests across multiple servers.

  1. How To Install HA Proxy? (For This Chat I’m on Ubuntu 18.04):
    sudo add-apt-repository ppa:vbernat/haproxy-1.8
    sudo apt-get update
    sudo apt-get install haproxy
    
  2. How To Setup HA Proxy?
    sudo vim /etc/haproxy/haproxy.cfg
    
    • the configuration file can look similar to the one here
  • The lines below are the focus for this quick chat
frontend proxy_server #define the listener
      bind *:80 #This forwards traffic to the local box indicated by *
      mode http # http traffic
      default_backend web_servers #what traffic needs to be forwarded
backend web_servers

  • note that web_servers above and here are the same b/c “web_servers” is an identifier for defining the backend
        mode http
        balance roundrobin
    
  • roundrobin is one balance scheme that allows for the two web servers below to switch back and forth
        server web01 10.0.5.100:80 #the ip and port of the first server you want to balance
        server web02 10.0.5.101:80 #ip and port of the second server you want to balance
    
  • Restart The Service
    sudo systemctl enable haproxy
    sudo systemctl start haproxy
    
  • There ya have it! Pretty Quick. Relatively Simple. Fairly Intuitive.

We went on a bare bones minimum config here, but if you need to set it up for enterprise or something larger or you just want to know more about the configurations, there’s a lot of great documentation out on the web.

After all, HA Proxy is the world’s fastest and most widely-used software load balancer!

As Always If You Have Questions Feel Free To HMU @j3st3rjam3s




comments powered by Disqus