An introduction to LBActive

0 Comments

I have run across applications that work good as a load balancer but fall short of being a great load balancer due to the fact that they only do passive health checks (check based on possible return code from back-end server) and do not have the ability to dynamically adjust the weight/preference of each back-end node based on an active check.

One of these is my personal favorite; Nginx.

Nginx is great. Unfortunately I am not in a situation where I can get the Plus version and so have to make due with the standard version for a while longer. As such, it was a no brainer for me when I finally decided to do something about the active dynamic checks and weighting.

LBActive is an active health check and dynamically adjusting assistant to services that do not offer these options natively. At the time of this writing LBActive supports only Nginx. I will be modularizing the code to support other applications in the future (squid, pound and delegate to name a few). LBActive is written in Python and is currently in production use in my cluster but is still only proof of concept. It works great but may have some bugs. If you any problems or have suggestions to make it even better just let me know.

The setup is a bit specific and allows for no deviation at the moment. I will walk you through an install on a Debian system so YMMV. Also LBActive currently only support round-robin and ip_hash upstream options only.

LBActive server install
1. mkdir /etc/nginx/upstreams-available
2. mkdir /etc/nginx/upstreams-enabled
3. nano /etc/nginx/upstreams-available/.conf
4. ln -s /etc/nginx/upstreams-available/
.conf /etc/nginx/upstreams-enabled/.conf then add you upstream block as you would normally in the nginx.conf
5. install the lbactive script to /opt/sbin/lbactive (or /usr/sbin/lbactive if you wish)
6. chmod 755 /opt/sbin/lbactive
7a. install the init script to /etc/init.d/lbactive (adjust if lbactive was installed in /usr/sbin)
7b. install the systemd script to /etc/systemd/system/lbactive.service
8. execute ‘update-rc.d lbactive enable’
9. add the following to /etc/nginx.conf ‘include /etc/nginx/sites-enabled/*.conf;’
10. mkdir /etc/lbactive
11. copy the lbactive.cfg to /etc/lbactive and modify as needed (the upstream block to reflect your installation)
12. follow the client install instructions and then do the last 2 steps below
13. restart/reload nginx
14. service lbactive start

Client install
1. copy the lb-feedback script to /opt/sbin
2. chmod 755 /opt/sbin/lb-feedback
3. add ‘lb-feedback stream tcp nowait root /opt/bin/lb-feedback’ to /etc/inetd.conf and restart
4. add ‘lb-feedback 3333/tcp # lbactive feedback daemon’ to /etc/services

You can get all the scripts from Sourceforge. I will be hammering out an install script soon to help trim the above list down a bit.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.