06-Load Balancing Configuration Guide

HomeSupportConfigure & DeployConfiguration GuidesH3C SecPath M9000 Configuration Guide(V7)(R9X71)-6W70106-Load Balancing Configuration Guide
02-Web cache policy configuration
Title Size Download
02-Web cache policy configuration 115.60 KB

Configuring a Web cache policy

About Web cache policies

A Web cache policy allows you to cache frequently accessed webpages locally in files. If a user accesses the same URI before the cached file expires, the device responds with the file instead of sending the request to the server. By using a Web cache policy, you can alleviate the pressure on the server, reduce the transmission costs, and reduce the response time for users.

Other functional modules (for example, an LB virtual server) can use a Web cache policy to cache frequently accessed webpages.

Figure 1 Web caching process

 

 

A Web cache policy works as follows:

1.     When the device receives an HTTP GET request from the host, it obtains the URI and searches for the URI in cached files.

¡     If a match is found, the device constructs a response and returns it to the host.

¡     If no match is found, the device proceeds to the next step.

2.     The device reconstructs an HTTP GET request and sends it to the server.

3.     After receiving the response from the server, the device checks whether the URI of the HTTP GET request can be cached.

¡     If yes, the device caches the response into a file, reconstructs a response, and sends it to the host.

¡     If not, the device reconstructs a response and sends it to the host.

Restrictions and guidelines: Web cache policy configuration

A Web cache policy supports data caching only for HTTP.

Web cache policy tasks at a glance

To configure a Web cache policy, perform the following tasks:

·     Creating a Web cache policy

·     Creating a URI match rule

·     (Optional.) Configure cache parameters

¡     Setting the aging time of cached files

¡     Setting the maximum size of cached files

¡     Setting the maximum size of a single cached file

Creating a Web cache policy

1.     Enter system view.

system-view

2.     Create a Web cache policy and enter Web cache policy view.

cache-policy cache-policy-name [ type http ]

The type http keywords are optional when you create a Web cache policy. If you specify them, you must also specify them when entering the view of an existing Web cache policy.

Creating a URI match rule

About this task

The device checks whether the URI of an HTTP request matches the URI specified in a match rule. If yes, the device caches the response of the request. If no match rule is configured, the device does not cache any responses.

Procedure

1.     Enter system view.

system-view

2.     Enter Web cache policy view.

cache-policy cache-policy-name [ type http ]

3.     Create a URI match rule.

match [ match-id ] uri uri

Setting the aging time of cached files

About this task

A cached file is deleted if the corresponding URI is not requested when the aging time expires.

Restrictions and guidelines

A cached file is automatically deleted when its aging timer expires.

The aging timer of a cached file is not restarted when the device receives the same HTTP requests as the first HTTP request that triggers the generation of the file.

If you modify the aging time, the new setting takes effect only on newly generated files and does not affect existing files.

Procedure

1.     Enter system view.

system-view

2.     Enter Web cache policy view.

cache-policy cache-policy-name [ type http ]

3.     Set the aging time of cached files.

aging-time time-value

The default setting is 60 minutes.

Setting the maximum size of cached files

About this task

When the total size of cached files reaches the configured maximum size, the device deletes the oldest cache files to save the new cache file.

Procedure

1.     Enter system view.

system-view

2.     Enter Web cache policy view.

cache-policy cache-policy-name [ type http ]

3.     Set the maximum size of cached files.

size size-value

The default setting is 64 MB.

Setting the maximum size of a single cached file

About this task

A file exceeding the maximum size is not cached.

Procedure

1.     Enter system view.

system-view

2.     Enter Web cache policy view.

cache-policy cache-policy-name [ type http ]

3.     Set the maximum size of a single cached file.

file-max-size file-size

The default setting is 2048 KB.

Display and maintenance commands for Web cache policies

Execute display commands in any view and reset commands in user view:

 

Task

Command

Display  Web cache policy information.

In standalone mode:

display cache-policy [ name cache-policy-name ] [ slot slot-number cpu cpu-number ]

In IRF mode:

display cache-policy [ name cache-policy-name ] [ chassis chassis-number slot slot-number cpu cpu-number  ]

Display statistics for Web cache policies.

display cache-policy statistics [ name cache-policy-name ]

Clear cached files for Web cache policies.

reset cache-policy [ cache-policy-name ]

Clear statistics for Web cache policies.

reset cache-policy statistics [ cache-policy-name ]

 

Web cache policy configuration examples

Example: Configuring a Web cache policy for Layer 7 server load balancing

Network configuration

As shown in Figure 2, configure Layer 7 server load balancing to load balance HTTP services between the two servers. Configure a Web cache policy to cache web pages, saving bandwidth and reducing workload of the servers.

Figure 2 Network diagram

Procedure

1.     Assign an IP address to GigabitEthernet 1/0/1.

<Device> system-view

[Device] interface gigabitethernet 1/0/1

[Device-GigabitEthernet1/0/1] ip address 10.1.1.1 24

[Device-GigabitEthernet1/0/1] quit

2.     Configure a Web cache policy:

# Create a Web cache policy named cp1 and enter its view.

[Device] cache-policy cp1 type http

# Configure a URI match rule to match URIs with index.

[Device-cp-http-cp1] match 1 uri index

[Device-cp-http-cp1] quit

3.     Configure Layer 7 server load balancing:

# Create a real server named rsa, specify its IPv4 address as 192.168.1.1, and add it to server farm sf.

[Device] real-server rsa

[Device-rserver-rsa] ip address 192.168.1.1

[Device-rserver-rsa] server-farm sf

[Device-rserver-rsa] quit

# Create a real server named rsb, specify its IPv4 address as 192.168.1.2, and add it to server farm sf.

[Device] real-server rsb

[Device-rserver-rsb] ip address 192.168.1.2

[Device-rserver-rsb] server-farm sf

[Device-rserver-rsb] quit

# Create an SNAT address pool named sp1, and specify the address range 192.168.1.166 to 192.168.1.166 for the pool.

[Device] loadbalance snat-pool sp1

[Device-lbsnat-pool-sp1] ip range start 192.168.1.166 end 192.168.1.166

[Device-lbsnat-pool-sp1] quit

# Create the server farm sf, and specify the SNAT address pool sp1 for it.

[Device] server-farm sf

[Device-sfarm-sf] snat-pool sp1

[Device-sfarm-sf] quit

# Create an HTTP virtual server named vs1 and specify its VSIP as 10.1.1.1. Specify the default primary server farm sf, specify Web cache policy cp1, and enable the virtual server.

[Device] virtual-server vs1 type http

[Device-vs-http-vs1] virtual ip address 10.1.1.1

[Device-vs-http-vs1] default server-farm sf

[Device-vs-http-vs1] lb-cache-policy cp1

[Device-vs-http-vs1] service enable

[Device-vs-http-vs1] quit

For more information about configuring server load balancing, see "Configuring server load balancing."

Verifying the configuration

# After a client sends an HTTP request with URI /index.php, display Web cache policy information.

[Device] display cache-policy

Policy name: cp1

  Type: HTTP

  State: Enabled

  Max size: 64 MB

  Single file size: 2048 KB

  Aging time: 60 min

  Match rule:

    match 1 uri index

  Slot 1:

  File list:

    Name           Type        Encoding    Language    Timeout   Matches  FileSize

    -------------------------------------------------------------------------------

  10.1.1.1/index.php  applicatio                          59        0        1200

                        n/octet-st

                        ream

  Total files: 1

# Display statistics for the Web cache policy.

<Device> display cache-policy statistics

Slot 2:

Cache policy: cp1

  Matching requests: 0

# Display statistics for the virtual server.

<Device> display virtual-server statistics

Slot 2:

Virtual server: vs1

  Total connections: 1

  Active connections: 0

  Max connections: 1

  Connections per second: 0

  Max connections per second: 1

  Client input: 1372 bytes

  Client output: 39937 bytes

  Throughput: 0 bytes/s

  Inbound throughput: 0 bytes/s

  Outbound throughput: 0 bytes/s

  Max throughput: 41309 bytes/s

  Max inbound throughput: 1372 bytes/s

  Max outbound throughput: 39937 bytes/s

  Received packets: 31

  Sent packets: 54

  Dropped packets: 0

  Received requests: 1

  Dropped requests: 0

  Sent responses: 1

  Dropped responses: 0

# Display statistics for the real server.

<Device> display real-server statistics

Slot 2:

Real server: rs1

  Total connections: 1

  Active connections: 0

  Max connections: 1

  Connections per second: 0

  Max connections per second: 1

  Server input: 1740 bytes

  Server output: 40633 bytes

  Throughput: 0 bytes/s

  Inbound throughput: 0 bytes/s

  Outbound throughput: 0 bytes/s

  Max throughput: 42373 bytes/s

  Max inbound throughput: 1740 bytes/s

  Max outbound throughput: 40633 bytes/s

  Received packets: 31

  Sent packets: 55

  Dropped packets: 0

  Received requests: 1

  Dropped requests: 0

  Sent responses: 1

  Dropped responses: 0

  Connection failures: 0

  Busy state: Normal

The output shows that no matching URI is found and a cached file is generated.

# After a client sends another HTTP request with the same URI, display Web cache policy information.

[Device] display cache-policy

Policy name: cp1

  Type: HTTP

  State: Enabled

  Max size: 64 MB

  Single file size: 2048 KB

  Aging time: 60 min

  Match rule:

    match 1 uri index

  Slot 1:

  File list:

    Name           Type        Encoding    Language    Timeout   Matches  FileSize

    -------------------------------------------------------------------------------

    10.1.1.1/index.php  applicatio                          59        1        1200

                        n/octet-st

                        ream

  Total files: 1

# Display statistics for the Web cache policy.

<Device> display cache-policy statistics

Slot 2:

Cache policy: cp1

  Matching requests: 1

# Display statistics for the virtual server.

<Device> display virtual-server statistics

Slot 2:

Virtual server: vs1

  Total connections: 2

  Active connections: 0

  Max connections: 1

  Connections per second: 0

  Max connections per second: 1

  Client input: 2464 bytes

  Client output: 79506 bytes

  Throughput: 0 bytes/s

  Inbound throughput: 0 bytes/s

  Outbound throughput: 0 bytes/s

  Max throughput: 41309 bytes/s

  Max inbound throughput: 1372 bytes/s

  Max outbound throughput: 39937 bytes/s

  Received packets: 55

  Sent packets: 94

  Dropped packets: 0

  Received requests: 2

  Dropped requests: 0

  Sent responses: 2

  Dropped responses: 0

# Display statistics for the real server.

<Device> display real-server statistics

Slot 2:

Real server: rs1

  Total connections: 1

  Active connections: 0

  Max connections: 1

  Connections per second: 0

  Max connections per second: 1

  Server input: 1740 bytes

  Server output: 40633 bytes

  Throughput: 0 bytes/s

  Inbound throughput: 0 bytes/s

  Outbound throughput: 0 bytes/s

  Max throughput: 42373 bytes/s

  Max inbound throughput: 1740 bytes/s

  Max outbound throughput: 40633 bytes/s

  Received packets: 31

  Sent packets: 55

  Dropped packets: 0

  Received requests: 1

  Dropped requests: 0

  Sent responses: 1

  Dropped responses: 0

  Connection failures: 0

  Busy state: Normal

The output shows that the Web cache policy was hit, the hit count incremented from 0 to 1, and the number of sent responses on the real server did not change (the request is serviced locally).

  • Cloud & AI
  • InterConnect
  • Intelligent Computing
  • Intelligent Storage
  • Security
  • SMB Products
  • Intelligent Terminal Products
  • Product Support Services
  • Technical Service Solutions
All Services
  • Resource Center
  • Policy
  • Online Help
  • Technical Blogs
All Support
  • Become A Partner
  • Partner Policy & Program
  • Global Learning
  • Partner Sales Resources
  • Partner Business Management
  • Service Business
All Partners
  • Profile
  • News & Events
  • Online Exhibition Center
  • Contact Us
All About Us
新华三官网