Home > Articles > Networking > Routing & Switching

Cisco LAN Switching Configuration : Server Load Balancing (SLB)

  • Print
  • + Share This
  • 💬 Discuss
This chapter is from the book
This chapter covers the steps required to load balance traffic to one or more server farms and firewall farms, and also explains the steps needed to define probes that test server and firewall farm functionality.

See the following sections to configure and use these features:

  • 10-1: SLB: Covers the configuration steps needed to provide load balancing of traffic to one or more server farms
  • 10-2: SLB Firewall Load Balancing: Discusses the configuration steps necessary to load balance traffic to one or more firewall farms
  • 10-3: SLB Probes: Explains the configuration steps needed to define probes that test server and firewall farm functionality

10-1: SLB

  • SLB provides a virtual server IP address to which clients can connect, representing a group of real physical servers in a server farm. Figure 10-1 shows the basic SLB concept. A client accesses a logical “virtual” server (IP address v.v.v.v), which exists only within the Catalyst 6500 SLB configuration. A group of physical “real” servers (IP addresses x.x.x.x, y.y.y.y, and z.z.z.z) is configured as a server farm. Traffic flows between clients and the virtual server are load balanced across the set of real servers, transparent to the clients.

    Figure 10-1

    Figure 10-1 SLB Concept

  • As clients open new connections to the virtual server, SLB decides which real server to use based on a load-balancing algorithm.
  • Server load balancing is performed by one of these methods:

    • Weighted round-robin: Each real server is assigned a weight that gives it the capability to handle connections, relative to the other servers. For a weight n, a server is assigned n new connections before SLB moves on to the next server.
    • Weighted least connections: SLB assigns new connections to the real server with the least number of active connections. Each real server is assigned a weight m, where its capacity for active connections is m divided by the sum of all server weights. SLB assigns new connections to the real server with the number of active connections farthest below its capacity.
  • With weighted least connections, SLB controls the access to a new real server, providing a slow start function. New connections are rate limited and allowed to increase gradually to keep the server from becoming overloaded.
  • The virtual server can masquerade as the IP address for all TCP and UDP ports of the real server farm. As well, the virtual server can appear as the IP address of a single port or service of a server farm.
  • Sticky connections enable SLB to assign new connections from a client to the last real server the client used.
  • SLB can detect a real server failure by monitoring failed TCP connections. SLB can take the failed server out of service and return it to service when it is working again.
  • SLB can use server Network Address Translation (NAT) to translate between the real and virtual server addresses if they reside on different Layer 3 subnets.
  • SLB can use client NAT to translate the source addresses of client requests into addresses on the server side of the SLB device. This is used when several SLB devices are operating so that return traffic can be sent to the correct SLB device.
  • SLB provides a control mechanism over incoming TCP SYN floods to the real servers. This can prevent certain types of denial-of-service attacks.
  • SLB can coexist with Hot Standby Router Protocol (HSRP) to provide a “stateless backup.” If one SLB router fails, a redundant router can take over the SLB function. However, existing SLB connections will be lost and will have to be reestablished from the client side.
  • IOS SLB can also operate as a Dynamic Feedback Protocol (DFP) load-balancing manager. The DFP manager collects capacity information from DFP agents running on the real servers.

Configuration

  1. Define a server farm.

    1. Assign a name to the server farm:

      (global) ip slb serverfarm serverfarm-name

      The server farm is identified by serverfarm-name (text string up to 15 characters).

    2. (Optional) Select a load-balancing algorithm for the server farm:

      (server-farm) predictor {roundrobin | leastconns}

      SLB selects a real server using roundrobin (weighted round-robin the default) or leastconns (weighted least connections).

    3. (Optional) Use server NAT:

      (server-farm) nat server

      By default, the virtual server and real server addresses must be Layer 2-adjacent. In other words, SLB forwards packets between the virtual server and a real server by substituting the correct MAC addresses. Server NAT can be used instead, allowing the virtual and real servers to have addresses from separate IP subnets. SLB then substitutes the Layer 3 IP addresses to forward packets between the virtual and real servers, allowing the servers to be separated by multiple routing hops.

    4. (Optional) Use client NAT.

      • Define a NAT pool of addresses:

        (global) ip slb natpool pool-name start-ip end-ip {netmask netmask |
        prefix-length leading-1-bits}[entries init-addr [max-addr]]

        A pool of IP addresses is given the name pool-name (text string up to 15 characters), consisting of addresses bounded by start-ip and end-ip. The subnet mask associated with the pool can be given as a regular subnet mask, netmask (x.x.x.x format), or as the number of leading 1 bits in the mask, leading-1-bits (1 to 32).

        For IOS SLB, client NAT allocates a number of entries as IP addresses and port numbers, init-addr (1 to 1,000,000; default 8000) as an initial set to use. When the number of dynamically allocated entries reaches half of the initial number, more entries are allocated. The maximum number of NAT entries can be defined as max-addr (1 to 8,000,000; default is the pool size times the number of ports available, or 65,535 to 11,000, or 54,535). Port numbers for translation begin at 11,000.

      • Enable client NAT with a pool:

        (server-farm) nat client pool-name

      The SLB NAT pool is identified by pool-name (up to 15 characters).

    5. (Optional) Assign a unique identifier for DFP:

      (server-farm) bindid [bind-id]

      Sometimes, a real server is assigned to multiple server farms. The bind-id (0 to 65533; default 0) is an arbitrary identification value given to a server farm. Each instance of a real server references this value, allowing DFP to assign a unique weight to it.

    6. (Optional) Test the server with a probe:

      (server-farm) probe name

      The probe defined as name (text string, up to 15 characters) periodically tests for server connectivity and operation. IOS SLB offers ping, HTTP, and Wireless Session Protocol (WSP) probes. The CSM also offers TCP, FTP, SMTP, Telnet, and DNS probes. See section “10-3: SLB Probes” for more information about configuring probes.

  2. Specify one or more real servers in the server farm.

    1. Identify the real server:

      (server-farm) real ip-address

      The real server has the IP address given by ip-address.

    2. (Optional) Specify a connection threshold.

      • Set the maximum number of connections:

        (real-server) maxconns number

      At any given time, the real server will be limited to number (1 to 4,294,967,295 connections; default 4,294,967,295) active connections.

    3. (Optional) Assign a relative capacity weight:

      (real-server) weight weighting-value

      The real server is assigned a weighting-value (1 to 255; default 8) that indicates its capacity relative to other real servers in the server farm. For weighted round-robin, weighting-value defines the number of consecutive connections the server receives before SLB moves to the next server. For weighted least connections, the next connection is given to the server whose number of active connections is furthest below its capacity. The capacity is computed as the weighting-value divided by the sum of all real server weighting values in the server farm.

    4. (Optional; IOS SLB only) Reassign connections when a server doesn’t answer:

      (real-server) reassign threshold

      SLB attempts to assign a new connection to a real server by forwarding the client’s initial SYN. If the server doesn’t answer with a SYN handshake before the client retransmits its SYN, an unanswered SYN is recorded. After threshold (1 to 4, default 3) unanswered SYNs occur, SLB reassigns the connection to the next server.

    5. (Optional; IOS SLB only) Define a failed server threshold:

      (real-server) faildetect numconns number-conns [numclients number-clients]

      A server is determined to have failed if number-conns (1 to 255, default 8 connections) TCP connections have been reassigned to another server. You can also use the numclients keyword to specify the number-clients (1 to 8, default 2) of unique clients that have had connection failures.

    6. (Optional; IOS SLB only) Specify the amount of time before retrying a failed server:

      (real-server) retry retry-value

      After a real server has been declared “failed,” SLB attempts to assign a new connection to it after retry-value (1 to 3600 seconds, default 60 seconds) time has elapsed. You can also use a value of 0 to indicate that new connections should not be attempted.

    7. Allow SLB to begin using the real server:

      (real-server) inservice

      By default, the real server is not used by SLB unless it is placed in service. To remove a server from service, use no inservice.

  3. Define a virtual server for the server farm.

    1. Name the virtual server:

      (global) ip slb vserver virtual-server-name

      The virtual server is given the name virtual-server-name (text string up to 15 characters).

    2. Assign the virtual server to a server farm:

      (virtual-server) serverfarm serverfarm-name

      SLB uses the virtual server as the front end for the server farm named serverfarm-name (text string up to 15 characters).

    3. Define the virtual server capabilities:

      (virtual-server) virtual ip-address [network-mask] {tcp | udp} [port | wsp
      | wsp-wtp | wsp-wtls | wsp-wtp-wtls] [service service-name]

      The virtual server appears as IP address ip-address (default 0.0.0.0 or “all networks”) with network-mask (default 255.255.255.255).

      With IOS SLB, it provides load balancing for the specified tcp or udp port: dns or 53 (Domain Name System), ftp or 21 (File Transfer Protocol), https or 443 (HTTP over Secure Socket Layer), www or 80 (HTTP), telnet or 23 (Telnet), smtp or 25 (SMTP), pop3 or 110 (POPv3), pop2 or 109 (POPv2), nntp or 119 (Network News Transport Protocol), or matip-a or 350 (Mapping of Airline Traffic over IP, type A). A port number of 0 can be given to indicate that the virtual server accepts connections on all ports.

      Other alternatives to a port number are wsp (connectionless WSP, port 9200), wsp-wtp (connection-oriented WSP, port 9201 with WAP FSM), wsp-wtls (connectionless secure WSP, port 9202), and wsp-wtp-wtls (connection-oriented secure WSP, port 9203).

      The service keyword can be given to force SLB to assign all connections associated with a given service-name (ftp or wsp-wtp) to the same real server. On a CSM, only ftp connections are allowed to be coupled to the originating control session.

    4. (Optional) Control access to the virtual server. To allow only specific clients to use the virtual server, enter

      (virtual-server) client ip-address network-mask

      Clients having IP addresses within the range given by ip-address (default 0.0.0.0, or all addresses) and network-mask (default 255.255.255.255, or all networks) are allowed to connect to the virtual server. The network-mask in this case resembles the mask of an access list, where a 1 bit ignores and a 0 bit matches. On a CSM, you can use the exclude keyword to disallow the IP addresses specified.

    5. (Optional) Assign connections from the same client to the same real server:

      (virtual-server) sticky duration [group group-id] [netmask netmask]

      For a given client, connections are assigned to the last-used real server for duration in seconds (0 to 65,535). Virtual servers can be assigned to a group-id (0 to 55; default 0), associating them as a single group. A netmask (default 255.255.255.255) can be given such that all client source addresses within the mask are assigned to the same real server.

    6. (Optional) Hold connections open after they are terminated:

      (virtual-server) delay duration

      After a TCP connection is terminated, SLB can maintain the connection context for duration (1 to 600 seconds, default 10 seconds). This can be useful when packets arrive out of sequence, and the connection is reset before the last data packet arrives.

    7. (Optional) Hold connections open after no activity:

      (virtual-server) idle duration

      When SLB detects an absence of packets for a connection, it keeps the connection open for duration in seconds (IOS: 10 to 65,535; default 3600 seconds or 1 hour) before sending an RST.

    8. (Optional) Prevent a SYN flood to the real servers:

      (virtual-server) synguard syn-count [interval]

      SLB monitors the number of SYNs that are received for the virtual server. If more than syn-count (0 to 4294967295; default 0 or no SYN monitoring) SYNs are received within the interval (50 to 5000 milliseconds; default 100 ms), any subsequent SYNs are dropped.

    9. (Optional) Control the advertisement of the virtual server:

      (virtual-server) advertise [active]

      By default, SLB creates a static route for the virtual server address to the Null0 logical interface. This static route can then be redistributed and advertised by a routing protocol. The active keyword causes the route to be advertised only when at least one real server is available. You can disable the advertisement with no advertise, preventing the static route from being created.

    10. Enable SLB to begin using the virtual server:

      (virtual-server) inservice [standby group-name]

      By default, the virtual server is not used by SLB unless it is placed in service. To remove a virtual server from service, use no inservice.

    11. (Optional) Use SLB stateful backup:

      (virtual-server) replicate casa listening-ip remote-ip port-number
      [interval] [password [0|7] password [timeout]]

      IOS SLB replicates and exchanges its load-sharing decision tables with other stateful backup devices using the Cisco Appliance Services Architecture (CASA) mechanism. When a failure occurs, the backup SLB device already has the current state information and can immediately take over.

      This information is sent from the listening-ip address (an interface on the local device) to the remote-ip address (an interface on the backup device), using TCP port port-number (1 to 65,535). Replication messages are sent at interval seconds (1 to 300, default 10).

      A password (text string; use 0 if unencrypted, the default, or 7 if encrypted) can be used for MD5 authentication with the backup device. The optional timeout (0 to 65,535 seconds; default 180 seconds) defines a time period when the password can be migrated from an old value to a new one. During this time, both old and new passwords are accepted.

      CSM replicates its connection information using the Content Switching Replication Protocol (CSRP). The sticky connection database or the regular connection database can be replicated. To replicate both, choose each one in a separate replicate csrp command.

  4. (Optional) Use SLB Dynamic Feedback Protocol (DFP).

    1. (Optional) Use the DFP manager to communicate with DFP agents on servers.

      • Enable the DFP manager:

        (global) ip slb dfp [password [0|7] password [timeout]]

        The router can become a DFP load-balancing manager. DFP can be configured with a password (text string; use 0 if unencrypted, the default, or 7 if encrypted) for MD5 authentication with a host agent. The optional timeout (0 to 65,535 seconds; default 180 seconds) defines a time period when the password can be migrated from an old value to a new one. During this time, both old and new passwords are accepted.

      • Specify a DFP agent:

        (slb-dfp) agent ip-address port-number [timeout [retry-count [retry-interval]]]

        A DFP agent on a real server is identified by its ip-address and the port-number number used. The DFP agent (the server) must contact the DFP manager (the IOS SLB device) at timeout intervals (0 to 65,535 seconds; default 0 seconds or no timeout period). The DFP manager attempts to reconnect to the agent retry-count (0 to 65,535 retries; default 0 retries or an infinite number) times, at intervals of retry-interval (1 to 65,535 seconds; default 180 seconds).

    2. (Optional) Use a DFP agent to provide DFP reports.

      • Define the agent:

        (global) ip dfp agent subsystem-name

        The DFP agent sends periodic reports to its manager, a distributed director device. The subsystem-name (text string up to 15 characters) enables the manager to associate the server reports with a subsystem (controlled by the SLB device) for global load balancing. To see what subsystem-name values are available from the global manager, use the ip dfp agent ? command.

      • (Optional) Set a DFP agent password:

        (dfp) password [0|7] password [timeout]

        A password (text string; use 0 if unencrypted, the default, or 7 if encrypted) can be used for MD5 authentication with a DFP manager. The optional timeout (0 to 65,535 seconds; default 180 seconds) defines a time period when the password can be migrated from an old value to a new one. During this time, both old and new passwords are accepted.

      • Set the DFP port number:

        (dfp) port port-number

        The DFP manager and agents communicate over a common port number, port-number (1 to 65535, no default). DFP managers discover their agents dynamically, requiring the port number to be identical between the manager (distributed director) and the agents (IOS SLB).

      • (Optional) Set the interval for recalculating weights:

        (dfp) interval seconds

        DFP server weights are recalculated at an interval of seconds (5 to 65,535 seconds; default 10 seconds) before they are supplied to the DFP manager.

      • Enable the DFP agent:

        (dfp) inservice

        By default, the DFP agent is disabled.

SLB Example

See Figure 10-2 for a network diagram. SLB is configured to provide load balancing for two server farms: FARM1 and FARM2.

Figure 10-2

Figure 10-2 Network Diagram for the SLB Example

FARM1 is a server farm of three real web servers having IP addresses 192.168.250.10, 192.168.250.11, and 192.168.250.12. The real servers are considered in a “failed” state if four consecutive TCP connections cannot be established with the server. SLB waits 30 seconds before attempting another connection to a failed server. (The number of failed TCP connections and the retry interval are supported only in the IOS command set.) An HTTP probe is configured to try a connection to each real server in the server farm every 120 seconds.

The virtual server VSERVER1 at 10.10.10.101 uses the weighted least connections algorithm for load balancing between the real servers. New connections are made sticky (passed to the real server last used by the same client) for 60 seconds.

The CSM version of this example also includes the client and server-side VLAN numbers (10 and 20) and IP addresses (10.10.10.2 and 192.168.250.1).

One server is given a weight of 32, one server has a weight of 16, and one server has a weight of 8. New connections are assigned to the server with the least number of active connections, as measured by the server capacities. For example, server 192.168.254.10 has a weight of 32 and a capacity of 32 /(32 + 16 + 8) or 32 / 56. Server 192.168.254.11 has a weight of 16 and a capacity of 16 /(32 + 16 + 8) or 16 / 56. Server 192.168.254.12 has a weight of 8 and a capacity of 8 /(32 + 16 + 8) or 8 / 56. At any given time, the server with the number of active connections furthest below its capacity is given a new connection.

The configuration that follows shows the commands that are necessary for server farm FARM1 and virtual server VSERVER1. The same configuration is shown for an IOS-based switch and a CSM module:

(global) ip slb serverfarm FARM1
(server-farm) predictor leastconns
(server-farm) nat server
(server-farm) probe HTTP1
(server-farm) real 192.168.250.10
(real-server) weight 32
(real-server) faildetect numconns 4
(real-server) retry 30
(real-server) inservice
(real-server) exit
(server-farm) real 192.168.250.11
(real-server) weight 16
(real-server) faildetect numconns 4
(real-server) retry 30
(real-server) inservice
(real-server) exit
(server-farm) real 192.168.250.12
(real-server) weight 8
(real-server) faildetect numconns 4
(real-server) retry 30
(real-server) inservice
(real-server) exit

(global) ip slb vserver VSERVER1
(virtual-server) serverfarm FARM1
(virtual-server) virtual 10.10.10.101 tcp www
(virtual-server) sticky 60 group 1
(virtual-server) advertise active
(virtual-server) inservice
(virtual-server) exit

(global) ip slb dfp password 0 test123
(slb-dfp) agent 192.168.250.10 2000
(slb-dfp) agent 192.168.250.11 2000
(slb-dfp) agent 192.168.250.12 2000
(slb-dfp) exit

(global) probe HTTP1 http
(probe) interval 120
(probe) port 80
(probe) request method get
(probe) exit

Displaying Information About SLB

Table 10-1 lists some switch commands that you can use to display helpful information about SLB configuration and status.

Table 10-1. Commands to Display SLB Configuration and Status Information

Display Function Command
Server farms (exec) show ip slb serverfarms
[name serverfarm-name] [detail]
Real servers (exec) show ip slb reals
[vserver virtual-server-name] [detail]
Virtual servers (exec) show ip slb vserver
[name virtual-server-name] [detail]
SLB connections (exec) show ip slb conns
[vserver virtual-server-name | client ip- address] [detail]
DFP status (exec) show ip slb dfp
[agent agent-ip-address port-number | manager manager-ip-address | detail | weights]
SLB redundancy (exec) show ip slb replicate
Probes (exec) show ip slb probe
[name probe_name] [detail]
SLB statistics (exec) show ip slb stats
  • + Share This
  • 🔖 Save To Your Account

Discussions

comments powered by Disqus