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
Procedure
Additional configuration rules that you can add with CBR and Site Selector
components
-
Rules based on the client IP address.
You might use rules based on the client IP address to screen the customers and allocate
resources based on where they are coming from. For
example:
cbrcontrol rule add 9.67.131.153@80@ni type ip beginrange 9.0.0.0 endrange 9.255.255.255
The
ni
rule screens out any connection from unwanted clients. You would then add to the
rule the servers that you want accessible, or if you do not add any servers to the rule, requests
coming from the
9.x.x.x
addresses are not served by any of your servers.
-
Rules based on the time of day.
You might use rules based on the time of day for capacity planning reasons. For
example:
cbrcontrol rule add 9.67.131.153@80@ni type time beginrange 3 endrange 4
When
defining the beginrange and endrange of time intervals, each value must be an integer representing
only the hour portion of the time; portions of an hour are not specified. To specify a single hour,
for example, the hour between 3:00 and 4:00 am, specify a beginrange of 3 and an endrange of 3. This
range signifies all the minutes beginning with 3:00 and ending with 3:59. Specifying a beginrange of
3 and an endrange of 4 covers the two-hour period from 3:00 through 4:59.
-
Rules based on the connections per second (CBR only).
Tip: The manager must be running for this scenario to work.
You might use
rules based on connections per second to share some of your servers with other applications. For
example, you can set two rules:
- If connections per second on port 80 is between 0 and 2000, then use these 2 servers
- If connections per second on port 80 is greater than 2000, then use these 10 servers
Setting rule evaluate option
upserversonrule
in conjunction with the
connection type rule: When using the connections type rule and setting the
upserversonrule
option, if some of the servers in the server set are down, then you
can ensure that the remaining servers will not overload. For more information, see the evaluate
option in the
dscontrol rule topic.
-
Metric all rule (Site Selector only).
For the metric all rule, choose a system metric (cpuload, memload, or your own customized
system metric script), and Site Selector compares the system metric value (returned by the Metric
Server agent residing in each load-balanced server) with the begin and end range that you specify in
the rule. Set the current system metric value for all the servers in the server within the range for
the rule to run.
Tip: The system metric script you choose must reside on each of the
load-balanced servers.
The following example describes how to add a metric all rule to your
configuration:
sscontrol rule add dnsload.com:allrule1 type metricall metricname cpuload beginrange 0 endrange 100
-
Metric average rule (Site Selector only).
For the metric average rule, you choose a system metric (cpuload, memload, or your own
customized system metric script), and Site Selector compares the system metric value (returned by
the Metric Server agent residing in each load-balanced server) with the begin and end range that you
specify in the rule. The average of the current system metric values for all the servers in the
server set must be within the range for the rule to run.
Tip: The system metric script
you choose must reside on each of the load-balanced servers.
The following example describes
how to add a metric average rule to your configuration:
sscontrol rule add dnsload.com:avgrule1 type metricavg metricname cpuload beginrange 0 endrange 100