Configure rules to manage traffic to busy or unavailable servers

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:
  1. 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.
  2. 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

  • 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

  • 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. Read “Server evaluation option for rules” on page for more information.
  • 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