Use rules-based load balancing to fine tune when and why packets are sent to which
servers. Load Balancer reviews any rules you add from first priority to last priority, stopping on
the first rule that it finds to be true, then load balancing the traffic between any servers
associated with the rule. It already balances the load based on the destination and port, but using
rules expands your ability to distribute connections.
About this task
You should use rules-based load balancing with Dispatcher and Site Selector when you want to use
a subset of your servers. Always use rules for the CBR component.
In most cases when configuring rules, you should configure a default always true rule in order to
catch any request that is passed by other higher priority rules. This default can be a "Sorry, the
site is currently down, try again later" response when all other servers fail for the client
request.
All rules have a name, type, priority, and might have a begin range and end range, along with a
set of servers. Rules are evaluated in priority order. A rule with a priority of 1 (lower number) is
evaluated before a rule with a priority of 2 (higher number). The first rule that is satisfied will
be used. When a rule has been satisfied, no further rules are evaluated. For a rule to be satisfied,
it must meet two conditions:
- The predicate of the rule must be true. That is, the value it is evaluating must be between the
begin and end ranges, or the content must match the regular expression that is specified in the
rule's pattern. For rules of type "true," the predicate is always satisfied, regardless of the begin
and end ranges. If a rule has no servers that are associated with it, the rule only needs to meet
this first condition to be satisfied. In this case, Load Balancer will drop the connection
request.
- If there are servers associated with the rule, at least one server must have a weight greater
than 0 to forward packets so Load Balancer will have a server to which connections can be
forwarded.
If a connection request does not satisfy any rules, Load Balancer will select a server from
the full set of servers available on the port.
Choose from the following types of rules:
- Dispatcher
- Active connections total
- Always true
- CBR
- Client IP address
- Time of day
- Connections per second
- Active connections total
- Always true
- Content of a request
- Site Selector
- Client IP address
- Time of day
- Metric all
- Metric average
- Always true
- Configure a rule that is based on the total active connections. You may want to use rules based on active connections total on a port if your servers get
overloaded and start throwing packets away. Certain Web servers will continue to accept connections
even though they do not have enough threads to respond to the request. As a result, the client
requests time out and the customer coming to your Web site is not served. You can use rules based on
active connections to balance capacity within a pool of servers. For example, you know from
experience that your servers will stop serving after they have accepted 250 connections.
Note: The manager must be running for the rules to work.
Create a rule using the dscontrol or cbrcontrol rule
command. You would then add to the rule your current servers plus some additional servers, which
will otherwise be used for other processing. For example:
dscontrol rule add 130.40.52.153@80@pool2 type active beginrange 250 endrange 500
- Create a rule that always evaluates as true. Such a rule will always be selected, unless all the servers associated with it are down.
Therefore, this rule should ordinarily be at a lower priority than other rules. You can even have
multiple "always true" rules, each with a set of servers that are associated with it. Load Balancer
will choose a rule based on the first rule that is true and has an available server.
For example,
assume you have six servers. You want two of them to handle your traffic under all circumstances,
unless they are both down. If the first two servers are down, you want a second set of servers to
handle the traffic. If all four of these servers are down, then you will use the final two servers
to handle the traffic. You could set up three "always true" rules, then the first set of servers
will always be chosen as long as at least one is up. If both servers are down, one from the second
set is chosen, and so forth.
As another example, you might want an "always true" rule to
ensure that if incoming clients do not match any of the rules you have set, they will not be served.
Then you would not add any servers to the rule, causing the clients packets to be dropped with no
response. You can define more than one "always true" rule, and thereafter adjust which one gets run
by changing their priority levels.
Create a rule using the dscontrol rule
command:dscontrol rule add 130.40.52.153@80@jamais type true priority 100
You
do not need to set a beginrange or endrange values when you create an always true rule.
- Add one or more servers to a rule set. You can use the dscontrol rule useserver command to add one or more servers to a rule set that
is already defined. For
example:
dscontrol rule useserver 130.40.52.153@80@jamais server1
dscontrol rule useserver 130.40.52.153@80@jamais server1+server2+server3
Additional configuration rules that you can add with CBR and Site Selector
components