The balance is a TCP proxy software with load balancing and failover capabilities. Support IPV6 address monitoring and forwarding, support RR polling and IP hash.
Some functions can be substituted for iptables, such as 80 port forwarding from local to 8080:
Iptables is written in this way:
Iptables-t nat-a prerouting-d 192.168.1.1-p tcp--dport 80-j DNAT--to 192.168.1.1:8080
Balance only need this:
Balance localhost:8080
First look at the official documentation:
Definitions:a possible destination consisting of a host address and a port is called a
"Channel". A channel is member of a "channel group". Channels is numbered in a group
Starting with 0. Groups is numbered starting with 0, which is the initial default group.
Balance accepts connections on the given ports and forwards them to the supplied channels.
At least one channel (in the default group) must is specified. If there is, or more
Channels specified in a group balance performs a simple round-robin load balancing between
The channels.
Balance allows the definition of further channel groups. The connection scheme works as
Follows:balance tries first to establish a connection to a channel in the first group
(0), performing the standard Round-robin load balancing scheme. If No channel in this
Group is available, balance proceeds with the next higher channel group. Groups is simply
Separated with a "!" at the command line at startup and can controlled interactively
With the "group" command.
A "%" instead of a "!" as a group separator declares the previous group to be of type
"Hash". This means the instead of a round-robin algorithm, a hash distribution based on
The client IP address is used to determine the destination channel. This allows connecting
One client always to the same server (e.g. balancing, HTTP sessions to a single server).
Hosts May is specified either by the hostname or by IP address. Ports may specified either
By name (as listed in/etc/services) or numerically. If no port is specified in a desti-
Nation, the destination port defaults to the source port, the balance controls.
Balance allows the specification of the maximum number of connections per channel. This
Parameter can optionally added after the port specification separated by a colon (":").
If a maximum number of connections is specified a channel would only being used for this maxi-
Mum number of simultaneous connections. A Maxc value of 0 denotes an unlimited number of
Connections. This is the initial default value of a channel.
The maximum number of groups and channels balance can handle are specified at compile time
And is initially-channels in groups.
The above content is relatively simple, it is not translated.
With balance's help documentation, you can implement the following functions:
One, forward the local 80 port to 8080:
Balance localhost:8080
Second, forward the local 80 port to web1 8080 port, web2 80 port to do RR load balance:
Balance web1:8080 WEB2
Third, forward the 80 port of the local IPv6 address to the 80 port of IPv4
Balance-b 2001:db8::1 80 10.1.1.1
Here's a look at the advanced usage of balance:
Four, web1, web2 do rotation, only if web1,2 have failed after forwarding to web3,! The role is to do channel groups segmentation, if the previous channel failure, then to the next channel groups.
Balance-f web1 WEB2! Web3
Five, balance can also be forwarded to the server to do a limit on the number of connections, when the number of WEB1 connections hit 256 to WEB2, when the number of WEB2 connections hit 128 to WEB3
Balance-f web1::256! web2::128! Web3
Six, if you want to do the session to keep words balance can also do, to use the%, so that the same user's request to reach the same server on the back end.
Balance-f web1 web2%
Effect
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/7F/80/wKiom1cgm-iAOKTTAACnZqJIuM8147.png "title=" Aaa.png "alt=" Wkiom1cgm-iaokttaacnzqjium8147.png "/>
This tool is for reference only, or for intranet environments, for more advanced functions, or for reference LVs.
Reference connection:
Https://www.linux.com/news/taking-load-load-balancing-balance
Balance official website:https://www.inlab.de/balance.html
Welcome to add!
This article is from "Tianya Horizon" blog, please be sure to keep this source http://shanker.blog.51cto.com/1189689/1768347
Lightweight network traffic forwarding tool-Balance