ISO simple non-forking TCP connection forward/balance tool
cswiger at mac.com
Fri Jan 22 21:06:50 UTC 2010
On Jan 22, 2010, at 12:21 PM, Adam Vande More wrote:
> A few lines in python should do what you're looking for, see socket lib,
> twisted if you have high performance needs.
I'm a big fan of python, but you'd have to be careful to choose the right processing model-- some sort of select()/poll()/kqueue() wrapper with nonblocking I/O and process-towards-completion semantics rather than trying to do multithreaded approach, since the GIL will really interfere with concurrency.
Note that the intended usage also matters quite a bit. For example, NAT-based solutions depend on the destinations being up all of the time and will happily drop a third (or whatever) of the traffic into the void if one of the backend boxes is down or a service is unresponsive. Software-based load-balancers which recognize and route around downed ports or boxes play nicer for this sort of thing, as do H/W load-balancer solutions like Foundry ServerIrons & Citrix NetScalers, which have liveness checks built in to test destinations and make sure they stay up before distributing traffic onto them.
There's also a question of whether the traffic ought to be stateful beyond individual connections, in which case software-based solutions like FastCGI or WebObjects which support session affinity are a much better idea than trying to write stateless services which have to persist to a backend database or something along those lines for every request.
More information about the freebsd-questions