[FreeNX-kNX] new load_balance_algorithm ?

Bastian Kames b.kames at ibg-monforts.de
Fri May 16 09:01:50 UTC 2008


Nice,

I do it like this.

example:

USERS=$(cat /var/lib/nxserver/db/running/* 2>1 |grep $1 | wc -l )

and

echo "1000 - $USER + (1000 - (100*$LOAD)) " | bc -q | cut -d. -f1


Am Freitag, 16. Mai 2008 10:46:19 schrieb Chris Fanning:
> Hi,
>
> I've been testing this out and it seems to work well.
> One problem I did have is when the hosts in LOAD_BALANCE_SERVERS are
> defined as IP's and not as names. So I just change the '.' to a '_'.
>
> I understand that good loadbalancing is tricky, but, don't you think
> that 'usercount' is better than 'random' and 'round-robin'?
>
> Cheers.
> Chris.
>
> server_loadbalance_usercount()
> {
>         log 5 "Info: Load-Balancing per user-count"
>         hosts_sessions=""
>         for i in $NX_SESS_DIR/running/*
>         do
>                 [ -f $i ] || break
>                 CMDLINE=$(session_get_cmdline $i)
>                 hosts_sessions=$hosts_sessions$(getparam host)" "
>         done
>
>         VAR="HOST"
>         for host in ${hosts_sessions}
>         do
>                 host_name=${host//./_}
>                 eval `echo $VAR$host_name`+=1
>         done
>
>         smallest_load=-1
>         for host in ${LOAD_BALANCE_SERVERS}
>         do
>                 host_name=${host//./_}
>                 varname=$VAR$host_name
>                 count=${!varname}
>                 log 5 "Info: host:$host  count:${#count}"
>                 if [ $smallest_load == -1 ]; then
>                         smallest_load=${#count}
>                         SERVER_LB_HOST=$host
>                 elif [ ${#count} -lt $smallest_load ]; then
>                         smallest_load=${#count}
>                         SERVER_LB_HOST=$host
>                 fi
>         done
>         echo $SERVER_LB_HOST
> }
>
>
> On Wed, May 14, 2008 at 5:54 PM, Chris Fanning
>
> <christopher.fanning at gmail.com> wrote:
> > 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
> > }
>
> ________________________________________________________________
>      Were you helped on this list with your FreeNX problem?
>     Then please write up the solution in the FreeNX Wiki/FAQ:
>   http://openfacts.berlios.de/index-en.phtml?title=FreeNX_FAQ
>          Don't forget to check the NX Knowledge Base:
>                  http://www.nomachine.com/kb/
>
> ________________________________________________________________
>        FreeNX-kNX mailing list --- FreeNX-kNX at kde.org
>       https://mail.kde.org/mailman/listinfo/freenx-knx
> ________________________________________________________________


---
IBG Monforts Service GmbH & Co. KG
 
Sitz der Gesellschaft: Moenchengladbach
Eingetragen beim Amtsgericht Moenchengladbach
Handelsregister-Nr. HRA 3688
USt-IdNr. DE 813 215 085
Persoenlich haftende Gesellschafterin: IBG Monforts Service Verwaltungs GmbH 
Geschaeftsfuehrer: Hans Peter Hansen
Eingetragen beim Amtsgericht Moenchengladbach
Handelsregister-Nr. HRB 6663



More information about the FreeNX-kNX mailing list