I am thinking of implementing a load balancing solution for personal use.
What I want to do, is to maximize data throughput over mobile phone Internet connections. Let me be clear:
I have data plan in my mobile phone and my family have their respective data plans in their phones, too. If I can connect up to 4 phones in one (desktop) PC (through USB preferably) then I will achieve (theoretically) a faster Internet connection than any one of the 4 phones can achieve (if I connect them to a PC).
That desktop computer will then act as a router for an intranet.
If the above has a sound basis (I could be wrong – don't know the technologies involved in great detail), I need a how to to implement that.
I have seen that the tool for the job is ipvs
(right?) but no how to.
Distro-wise the job can be done in any distro, but I know that connecting an Android phone with Ubuntu works plug and play.
So If I can do it in Ubuntu, it will probably be faster than compiling everything from strach.
Is there a relative how to? Is there a distro perhaps that does load balancing, and identifies USB internet connections on the fly?
Best Answer
To balance outgoing connections all you need is standard
iptables
and some policy routing. This does get a bit complex with 4 connections as you will need to reconfigure and rebalance the links as connections come and go.The raw
iptables
setup isCreate a routing table for each connection
Add the default gateway for each connection to each table (the gateway IP will vary depending on each phones provider/setup)
Randomly mark any unmarked flows, which will route the flow via a specific connection.
OUTPUT
is used for local processes. UsePREROUTING
if you are forwarding traffic for other clients)NAT for each of the connections (the interface will need to be whatever you phone connection appears to the system as)
Note that a single TCP or UDP connection will see no speed up as it will still be going over a single link. You have to use multiple concurrent connections (at least 4) to make use of the extra bandwidth. Most browsers do this under the hood when requesting multiple objects. Some download managers allow you to use multiple connections for a single file.
As garethTheRed suggests,
ispunity
adds some of the "glue" on top of thisiptables
setup to loop through a list of connections, check that the gateway is responding, re balance if something is wrong etc. It's "sticky session" management looks to be additional setup per port on top of it's base "round robin" load balancing of connections. Another solution is Net-ISP-Balance, a Perl script and library that automates the iptables and routing table configuration, monitors the ISP status, alerts you to problems, and reconfigures the routing in case one or more ISPs become inacessible.Also note that having requests come from multiple IP's can break some services that are based on consistent IP lookups and you may need to add additional rules for those services to tie them to a connection. You won't see any speedup on single connections, only when you are doing 4 things at once, which most browsers will try to do anyway.
ipvs
is more for creating a virtual service addresses for things you host so the service can be failed over between multiple hosts.