This example describes the configuration of HTTP server load balancing.
As shown in Figure 1, an enterprise has three web servers: Server1, Server2, and Server3. The hardware performance of the servers decreases in sequence. Server1 performance is twice of Server2 performance. Server2 performance is twice of Server3 performance. SLB is configured to allow the three servers to provide HTTP services as a whole. The carried services match the server hardware performance. In addition, the health check function is configured to monitor the work of the servers.
<FW> system-view [FW] interface GigabitEthernet 0/0/1 [FW-GigabitEthernet0/0/1] ip address 1.1.1.1 24 [FW-GigabitEthernet0/0/1] quit [FW] interface GigabitEthernet 0/0/2 [FW-GigabitEthernet0/0/2] ip address 192.168.1.254 24 [FW-GigabitEthernet0/0/2] quit [FW] firewall zone untrust [FW-zone-untrust] add interface GigabitEthernet 0/0/1 [FW-zone-untrust] quit [FW] firewall zone dmz [FW-zone-dmz] add interface GigabitEthernet 0/0/2 [FW-zone-dmz] quit
# Configure an Untrust -> DMZ security policy to allow Internet users to access web servers on the enterprise network. The destination IP address specified in the policy must be the IP address of the virtual server.
[FW] security-policy [FW-policy-security] rule name policy1 [FW-policy-security-rule-policy1] source-zone untrust [FW-policy-security-rule-policy1] destination-zone dmz [FW-policy-security-rule-policy1] destination-address 1.1.1.10 24 [FW-policy-security-rule-policy1] action permit [FW-policy-security-rule-policy1] quit [FW-policy-security] quit
# Configure a Local -> DMZ security policy to allow the FW to send health probe packets to the real servers.
[FW] security-policy [FW-policy-security] rule name policy2 [FW-policy-security-rule-policy2] source-zone local [FW-policy-security-rule-policy2] destination-zone dmz [FW-policy-security-rule-policy2] destination-address range 192.168.1.1 192.168.1.3 [FW-policy-security-rule-policy2] action permit [FW-policy-security-rule-policy2] quit [FW-policy-security] quit
# Enable SLB.
[FW] slb enable
# Configure the sticky session function.
[FW] slb [FW-slb] persistence 0 Session [FW-slb-persistence-1] type cookie-insert aging-time 600 [FW-slb-persistence-1] quit
# Configure a load balancing algorithm.
[FW-slb] group 0 Rserver [FW-slb-group-0] metric weight-least-connection
# Set the weights of Server1, Server2, and Server3 to 4, 2, and 1 separately.
[FW-slb-group-0] rserver 0 rip 192.168.1.1 port 8080 weight 4 description server1 [FW-slb-group-0] rserver 1 rip 192.168.1.2 port 8080 weight 2 description server2 [FW-slb-group-0] rserver 2 rip 192.168.1.3 port 8080 weight 1 description server3
# Configure the health check function.
[FW-slb-group-0] health-check type icmp tx-interval 5 times 3 [FW-slb-group-0] quit
# Configure a protocol type for the virtual server.
[FW-slb] vserver 0 vs-http-1.1.1.10 [FW-slb-vserver-0] protocol http
# Assign an IP address and a port number to the virtual server.
[FW-slb-vserver-0] vip 0 1.1.1.10 [FW-slb-vserver-0] vport 80
# Configure the sticky session function.
[FW-slb-vserver-0] persistence Session
# Associate the virtual server with the real server group.
[FW-slb-vserver-0] group Rserver [FW-slb-vserver-0] quit
Check static server map entries on the FW. If corresponding server map entries exist, the server load balancing is successfully configured.
[FW] display firewall server-map static
Current Total Server-map : 1
Type: SLB, ANY -> 1.1.1.10:80[vs-http-1.1.1.10/0], Zone:---, protocol:tcp
Vpn: public -> public
On the client, access http://1.1.1.10. The client can connect to an HTTP server.
Send a lot requests to the servers. After a period of time, view the running status of the virtual server and real servers on the FW. The total and concurrent session ratios of the three servers are about 4:2:1.
[FW] display slb vserver verbose vs-http-1.1.1.10 Virtual Server Information(Total 1) ------------------------------------------------------------------------------------------- Virtual Server Name : vs-http-1.1.1.10 Virtual Server ID : 0 Virtual Server IP : 1.1.1.10 Protocol : http Virtual Server Port : 80 Http X-forward Enable : Disable Virtual Server Max-conn : - Persistence Name/ID(Type): Session/0(cookie-insert) Group Name : vs-http-1.1.1.10 Group ID : 0 Virtual Server Statistics Current Connection :215 Total connection :400 Total Flow :12478.0_B --------------------------------------------- [FW] display slb group verbose Rserver Group Information(Total 1) -------------------------------------------------------------------------------- ---------------------------- Group Name : Rserver Group ID : 0 Metric : weight-least-connection Source-nat Type : NA Health Check Type : icmp Real Server Number : 3 RserverID IP Address Weight Max-connection Status Rat io TotalSession CurSession 0 192.168.1.1 4 - Admin-Active 57. 85% 4112 126 1 192.168.1.2 2 - Admin-Active 28. 11% 1998 63 2 192.168.1.3 1 - Admin-Active 14. 04% 998 31 -------------------------------------------------------------------------------- ----------------------------
# interface GigabitEthernet 0/0/1 ip address 1.1.1.1 24 # interface GigabitEthernet 0/0/2 ip address 192.168.1.254 24 # firewall zone untrust add interface GigabitEthernet 0/0/1 # firewall zone dmz add interface GigabitEthernet 0/0/2 # security-policy rule name policy1 source-zone untrust destination-zone dmz destination-address 1.1.1.10 24 action permit rule name policy2 source-zone local destination-zone dmz destination-address range 192.168.1.1 192.168.1.3 action permit # slb enable # slb group 0 Rserver metric weight-least-connection health-check type icmp tx-interval 5 times 3 rserver 0 rip 192.168.1.1 port 8080 weight 4 description server1 rserver 1 rip 192.168.1.2 port 8080 weight 2 description server2 rserver 2 rip 192.168.1.3 port 8080 weight 1 description server3 persistence 0 Session type cookie-insert aging-time 600 vserver 0 vs-http-1.1.1.10 vip 0 1.1.1.10 protocol http persistence Session vport 80 group Rserver