Load balancing Remote Desktop Services using Pen, a load balancer for “simple” tcp based protocols such as http or smtp.
It allows several servers to appear as one to the outside and automatically detects servers that are down and distributes clients among the available servers. This gives high availability and scalable performance.
We will use CentOS for this example:
yum install pen
You can also build it from source but this is not in the scope of this tutorial.
Run Pen on Startup
Pen supports a config file located at /etc but in order to use pen for multiple port balancing you will need to launch it manually.
We have created a manual startup command and added it to /etc/rc.d/rc.local
You will need to add this command for every Port you want to balance.
Pen Command Overview
-w - Web export file location -x - Amount of session -l - Log file location -C - Local Port (Make sure it is not used by anything else) -S - Amount of servers -r - Remote Port to balance
Load balancing Remote Desktop Services using Pen
You can use Pen to load balance Remote Desktop sessions – port 3389,
To enable on startup – add this command to /etc/rc.d/rc.local:
#!/bin/bash /usr/bin/killall pen /usr/bin/pen \ -w /var/www/html/stats.html \ -x 500 \ -l /var/log/pen.log \ -C 127.0.0.1:13389 \ -S 4 \ -r 3389 \ 10.0.0.111:3389 \ 10.0.0.112:3389 \ 10.0.0.113:3389 \ 10.0.0.114:3389
Pen Web Interface
Pen supports exporting session information to an html page so you can enable httpd and monitor the sessions and servers status:
yum install httpd chkconfig httpd on service httpd start
Create an update script
press “a” to get into edit mode and paste your content.
#!/bin/bash /usr/bin/penctl 127.0.0.1:13389 status > /var/www/html/index.html
use “esc” and then “shit+q” and finally save with “x” press enter.
Schedule script to run periodicity:
use “crontab -e” to edit crontab:
*/1 * * * * root /scripts/penwebd.sh