LVS
lvs-users
Google
 
Web LinuxVirtualServer.org

Re: [lvs-users] Load balancing outgoing traffic

To: "LinuxVirtualServer.org users mailing list." <lvs-users@xxxxxxxxxxxxxxxxxxxxxx>
Subject: Re: [lvs-users] Load balancing outgoing traffic
From: Greg <greg@xxxxxxxxxxxxx>
Date: Thu, 07 Feb 2008 15:23:31 +0100
Michael M. a écrit :
> You know, I had this exact same problem happen to me back in late 2006. I
> thought maybe I just didn't know what I was doing anymore, good to see I'm
> not the only one, bad to see it's still happening. I never did find a
> solution, and I tweaked every parameter I could find, no matter what I did,
> certain ips saw more traffic than others, everytime.
>
> I hope to see a solution, if anyone finds one, please post it here.
>   

Hi,

I found a solution !! Using iptables and nth.

First, I was using this method :

iptables -t nat -A POSTROUTING -m state --state NEW -m statistic --mode 
nth --every 2 --packet 0 -j SNAT --to-source $SIP1
iptables -t nat -A POSTROUTING -m state --state NEW -m statistic --mode 
nth --every 2 --packet 1 -j SNAT --to-source $SIP2
iptables -t nat -A POSTROUTING -m state --state NEW -j SNAT --to-source 
$SIP3


then, ping flood an "internet server", and make some stats, the 
"default" IP have the most traffic, ~40%, and the 3 round-robin IP have 
~25, 20 and 15% ...


Now, I use the same method, but with marks... and I got a really good 
load-balancing.

IPT=iptables
ETHNET=eth1
IPRANGE="`seq 145 149; seq 206 220`"
PORTS="24,90"
        i=0
        ipcount=`echo $IPRANGE | wc -w`
        for ip in $IPRANGE
        do
                $IPT -t mangle -A POSTROUTING -o $ETHNET -p tcp -m 
multiport --destination-ports $PORTS -m state --state NEW -m statistic 
--mode nth --every $ipcount --packet $i -j MARK --set-mark 1$i

                $IPT -t nat -A POSTROUTING -o $ETHNET -m mark --mark 1$i 
-j SNAT --to-source nnn.nnn.nnn.$ip
                i=$(( $i + 1 ))
        done


Regards,

-- 
Greg



<Prev in Thread] Current Thread [Next in Thread>