Cisco LAN Switching Configuration : Server Load Balancing (SLB)
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-1shows 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-1SLB 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 weightn, a server is assignednnew connections before SLB moves on to the next server.
- Weighted least connections:智慧SLB分配新连接到真正的服务器h the least number of active connections. Each real server is assigned a weightm, where its capacity for active connections ism除以所有服务器权重的总和。智慧SLB分配新连接到真正的服务器h 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.
- Stickyconnections 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 useserver Network Address Translation (NAT)to translate between the real and virtual server addresses if they reside on different Layer 3 subnets.
- SLB can useclient NATto 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 withHot 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 aDynamic Feedback Protocol (DFP)load-balancing manager. The DFP manager collects capacity information from DFP agents running on the real servers.
Configuration
Define a server farm.
Assign a name to the server farm:
(global)ip slb serverfarmserverfarm-name
The server farm is identified byserverfarm-name(text string up to 15 characters).
(Optional)Select a load-balancing algorithm for the server farm:
(server-farm)predictor{肾阳ndrobin|leastconns}
SLB selects a real server using肾阳ndrobin(weighted round-robin the default) orleastconns(weighted least connections).
(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.
(Optional)Use client NAT.
定义一个NAT地址池:
(global)ip slb natpoolpool-name start-ip end-ip{netmasknetmask|prefix-lengthleading-1-bits}[entriesinit-addr[max-addr]]
A pool of IP addresses is given the namepool-name(text string up to 15 characters), consisting of addresses bounded bystart-ipandend-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 asmax-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 clientpool-name
The SLB NAT pool is identified bypool-name(up to 15 characters).
(Optional)Assign a unique identifier for DFP:
(server-farm)bindid[bind-id]
Sometimes, a real server is assigned to multiple server farms. Thebind-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.
(Optional)Test the server with a probe:
(server-farm)probename
The probe defined asname(text string, up to 15 characters) periodically tests for server connectivity and operation. IOS SLB offers ping, HTTP, andWireless 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.
Specify one or more real servers in the server farm.
Identify the real server:
(server-farm)realip-address
The real server has the IP address given byip-address.
(Optional)Specify a connection threshold.
Set the maximum number of connections:
(real-server)maxconnsnumber
At any given time, the real server will be limited tonumber(1 to 4,294,967,295 connections; default 4,294,967,295) active connections.
(Optional)Assign a relative capacity weight:
(real-server)weightweighting-value
The real server is assigned aweighting-value(1 to 255; default 8) that indicates its capacity relative to other real servers in the server farm. For weighted round-robin,weighting-valuedefines 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 theweighting-valuedivided by the sum of all real server weighting values in the server farm.
(Optional; IOS SLB only)Reassign connections when a server doesn’t answer:
(real-server)reassignthreshold
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. Afterthreshold(1 to 4, default 3) unanswered SYNs occur, SLB reassigns the connection to the next server.
(Optional; IOS SLB only)Define a failed server threshold:
(real-server)faildetect numconnsnumber-conns [numclientsnumber-clients]
A server is determined to have failed ifnumber-conns(1 to 255, default 8 connections) TCP connections have been reassigned to another server. You can also use thenumclientskeyword to specify thenumber-clients(1 to 8, default 2) of unique clients that have had connection failures.
(Optional; IOS SLB only)Specify the amount of time before retrying a failed server:
(real-server)retryretry-value
After a real server has been declared “failed,” SLB attempts to assign a new connection to it afterretry-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.
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, useno inservice.
Define a virtual server for the server farm.
Name the virtual server:
(global)ip slb vservervirtual-server-name
The virtual server is given the namevirtual-server-name(text string up to 15 characters).
Assign the virtual server to a server farm:
(virtual-server)serverfarmserverfarm-name
SLB uses the virtual server as the front end for the server farm namedserverfarm-name(text string up to 15 characters).
Define the virtual server capabilities:
(virtual-server)virtualip-address [network-mask] {tcp|udp} [port |wsp|wsp-wtp|wsp-wtls|wsp-wtp-wtls] [serviceservice-name]
The virtual server appears as IP addressip-address(default 0.0.0.0 or “all networks”) withnetwork-mask(default 255.255.255.255).
With IOS SLB, it provides load balancing for the specifiedtcporudpport:dnsor53(Domain Name System),ftpor21(File Transfer Protocol),httpsor443(HTTP over Secure Socket Layer),wwwor80(HTTP),telnetor23(Telnet),smtpor25(SMTP),pop3or110(POPv3),pop2or109(POPv2),nntpor119(Network News Transport Protocol), ormatip-aor350(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 arewsp(connectionless WSP, port 9200),wsp-wtp(connection-oriented WSP, port 9201 with WAP FSM),wsp-wtls(connectionless secure WSP, port 9202), andwsp-wtp-wtls(connection-oriented secure WSP, port 9203).
Theservicekeyword can be given to force SLB to assign all connections associated with a givenservice-name(ftporwsp-wtp) to the same real server. On a CSM, onlyftpconnections are allowed to be coupled to the originating control session.
(Optional)Control access to the virtual server. To allow only specific clients to use the virtual server, enter
(virtual-server)clientip-address network-mask
Clients having IP addresses within the range given byip-address(default 0.0.0.0, or all addresses) andnetwork-mask(default 255.255.255.255, or all networks) are allowed to connect to the virtual server. Thenetwork-maskin 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 theexcludekeyword to disallow the IP addresses specified.
(Optional)Assign connections from the same client to the same real server:
(virtual-server)stickyduration [groupgroup-id] [netmasknetmask]
For a given client, connections are assigned to the last-used real server fordurationin seconds (0 to 65,535). Virtual servers can be assigned to agroup-id(0 to 55; default 0), associating them as a single group. Anetmask(default 255.255.255.255) can be given such that all client source addresses within the mask are assigned to the same real server.
(Optional)Hold connections open after they are terminated:
(virtual-server)delayduration
After a TCP connection is terminated, SLB can maintain the connection context forduration(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.
(Optional)Hold connections open after no activity:
(virtual-server)idleduration
When SLB detects an absence of packets for a connection, it keeps the connection open fordurationin seconds (IOS: 10 to 65,535; default 3600 seconds or 1 hour) before sending an RST.
(Optional)Prevent a SYN flood to the real servers:
(virtual-server)synguardsyn-count [interval]
SLB monitors the number of SYNs that are received for the virtual server. If more thansyn-count(0 to 4294967295; default 0 or no SYN monitoring) SYNs are received within theinterval(50 to 5000 milliseconds; default 100 ms), any subsequent SYNs are dropped.
(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. Theactivekeyword causes the route to be advertised only when at least one real server is available. You can disable the advertisement withno advertise, preventing the static route from being created.
Enable SLB to begin using the virtual server:
(virtual-server)inservice[standbygroup-name]
By default, the virtual server is not used by SLB unless it is placed in service. To remove a virtual server from service, useno inservice.
(Optional)Use SLB stateful backup:
(virtual-server)replicate casalistening-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 theCisco 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 thelistening-ipaddress (an interface on the local device) to theremote-ipaddress (an interface on the backup device), using TCP portport-number(1 to 65,535). Replication messages are sent atintervalseconds (1 to 300, default 10).
Apassword(text string; use0if unencrypted, the default, or7if encrypted) can be used for MD5 authentication with the backup device. The optionaltimeout(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 theContent Switching Replication Protocol (CSRP). Thestickyconnection database or the regularconnectiondatabase can be replicated. To replicate both, choose each one in a separatereplicate csrpcommand.
(Optional) Use SLB Dynamic Feedback Protocol (DFP).
(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 apassword(text string; use0if unencrypted, the default, or7if encrypted) for MD5 authentication with a host agent. The optionaltimeout(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)agentip-address port-number[timeout[retry-count[retry-interval]]]
A DFP agent on a real server is identified by itsip-addressand theport-numbernumber used. The DFP agent (the server) must contact the DFP manager (the IOS SLB device) attimeoutintervals (0 to 65,535 seconds; default 0 seconds or no timeout period). The DFP manager attempts to reconnect to the agentretry-count(0 to 65,535 retries; default 0 retries or an infinite number) times, at intervals ofretry-interval(1 to 65,535 seconds; default 180 seconds).
(Optional)Use a DFP agent to provide DFP reports.
Define the agent:
(global)ip dfp agentsubsystem-name
The DFP agent sends periodic reports to its manager, a distributed director device. Thesubsystem-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 whatsubsystem-namevalues are available from the global manager, use theip dfp agent ?command.
(Optional)Set a DFP agent password:
(dfp)password[0|7]password[timeout]
Apassword(text string; use0if unencrypted, the default, or7if encrypted) can be used for MD5 authentication with a DFP manager. The optionaltimeout(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)portport-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)intervalseconds
DFP server weights are recalculated at an interval ofseconds(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
SeeFigure 10-2for a network diagram. SLB is configured to provide load balancing for two server farms: FARM1 and FARM2.
Figure 10-2Network 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 [nameserverfarm-name] [detail] |
Real servers | (exec)show ip slb reals [vservervirtual-server-name] [detail] |
Virtual servers | (exec)show ip slb vserver [namevirtual-server-name] [detail] |
SLB connections | (exec)show ip slb conns [vservervirtual-server-name|clientip- address] [detail] |
DFP status | (exec)show ip slb dfp [agentagent-ip-address port-number|managermanager-ip-address|detail|weights] |
SLB redundancy | (exec)show ip slb replicate |
Probes | (exec)show ip slb probe [nameprobe_name] [detail] |
SLB statistics | (exec)show ip slb stats |