[FreeNX-kNX] new load_balance_algorithm ?

Chris Fanning christopher.fanning at gmail.com
Wed May 14 15:54:40 UTC 2008


Hi,

I'd like to try to loadbalance by the number of running sessions on each node.
The new session is opened on the node with the least connected users.
Perhaps something like this.

Any thoughts?

server_loadbalance_usercount()
	node_sessions=""
	for i in $NX_SESS_DIR/running/*
	do
		[ -f $i ] || break
		CMDLINE=$(session_get_cmdline $i)
		node_sessions=$node_sessions$(getparam host)" "	
	done

	VAR="NODE"
	for node in ${node_sessions}
	do
	        eval `echo $VAR$node`+=1
	done

	smallest_load=-1
	for node in ${LOAD_BALANCE_SERVERS}
	do
	        varname=$VAR$node
	        count=${!varname}
	        #echo "node: $node, count: ${#count}"
	        if [ $smallest_load == -1 ]; then
	                smallest_load=${#count}
	                SERVER_LB_HOST=$node
	        elif [ ${#count} -lt $smallest_load ]; then
	                smallest_load=${#count}
	                SERVER_LB_HOST=$node
	        fi
	done
	echo $SERVER_LB_HOST
}



More information about the FreeNX-kNX mailing list