[FreeNX-kNX] nxserver loadbalance.

Dimitar Paskov pascoff at nola7.com
Fri Apr 13 15:39:03 UTC 2007


> Dimitar Paskov wrote:
> > If you are interested I can give you more detail of the whole setup.
>
> Yes please

Ok, here it goes ...

A little pre history. We use nx technology for half a year (or more) and we 
use it in thin client environment. For now we have about 26 thin clients = 26 
users working on 3 servers split in one server (Athlon 64 X2 Dual Core 4600+, 
4GB) for 14 and 2 servers (Athlon 64 Processor 3000+, 2GB) for 6 users each. 
We had 6 servers (Sempron 2600+, 1,5GB) with 4/5 users per server but after 
some tests we found that the best compromise between price and performance is 
a dual core AMD processor with 4GB of memory that can hold up to 14-15 users 
but is more likely to limit it to 10-12 users. we are in process of changing 
the other servers. We are using this software in Kubuntu 6.06:
- freenx 0.5 (modified a little bit)
- nxagent 1.4.92+1.5.0-11ubuntu1
- nxclient 1.5.0-141 (modified a little bit)
- nxdesktop 1.4.92+1.5.0-11ubuntu1
- nxproxy 1.4.92+1.5.0-4ubuntu0

So the thin client boots from network and runs X with nxclient as only 
application with ion2 window manager (the only one I found that can be 
configured to display application in full screen). We changed nxclient and 
put a little function to execute an external program/script which returns the 
hostname/ipaddress of the server to which nxclient should connect to based on 
the username passed to it. This script connects to a mysql database which 
holds the information of nxsessions and server load balancing information. If 
the user has already running session the script returns the server on which 
it is started. If not it check the database for the least loaded server and 
returns it. We moved the information in /var/lib/nxserver/db/running/ that 
holds session info into database so it can be accessed from anywhere. This is 
done by modifying the source of nxserver to execute mysql queries instead of 
writing/reading session files.
Load balancing is done by 2 scripts. One is running on every server through 
cron every minute and checks how many users are logged in by "watching" how 
many nxagents are running. It calculates how many users are allowed for 
logging in this server by predefined parameters like CPU and memory 
information. For example we tested and decided to give 333MHz/340MB resource 
for a single user thus for 2GB memory we have about 6 users (memory is takes 
precedence over cpu in our case). When the script calculates its resources it 
writes in the database how many free and logged users it has. The other 
script is the one that nxclient executes which checks in this databases which 
server has less resources.
Next nxclient connects to the less loaded server. Every server has nxserver, 
nxnode and nxagent installed. Nxserver writes the session information to the 
mysql database and connects to nxnode/nxagent on localhost. We can connect as 
many servers as we need to the cluster and they will be instantly available. 
One interesting moment is that our servers are "thin" servers (like the 
clients), they do NOT have hard drives but mount read only their root / 
(/home is rw on another nfs file server) from a master nfs server which 
serves the images of the clients and servers. This master server has its 
replicator/backup server made with heartbeat and drbd (which holds the 
images) and if a disaster happens with the master, the backap becomes master 
and takes all the resources from it. mysql and tftp (which is used for 
network booting) are running on the master as well as nfs. If some server 
crashes (hardware failure) some of the users will lose their sessions but the 
machine can be replaced in a couple of minutes and they can continue working. 
Not the ultimate but working high availability solution.
So when we need a workstation or additional server power we just take a 
machine and plug it in the power and the network and it works :)
Users run regular kde environment, openoffice, firefox, etc. and a windows 
application through wine. Thin servers are just regular but more powerful 
workstations with kubuntu.
Of course there are some problems left unresolved but as a whole it is a very 
good solution to our company. For now it works only in local area network but 
we plan to make it work over internet.

I hope that you understand my writings :) If any questions arise, don't 
hesitate to ask!



More information about the FreeNX-kNX mailing list