Configuring Oracle Web Cache for Session Binding and Load Balancing

 

Purpose

This tutorial describes how to configure Oracle Web Cache for session binding and load balancing.

Time to Complete

Approximately 30 minutes.

Overview

Oracle Web Cache can distribute load among multiple origin servers via HTTP or HTTPS. For applications that use sessions, Oracle Web Cache performs session binding to the origin servers as well.

Software and Hardware Requirements (Optional)

The following is a list of software requirements:

Item Specification
Processor Type Intel Xeon or Pentium IV
Processor Speed 2.4 GHz or higher
Number of Processors 1 or more (if required)
Memory 2 GB
Hard Disk Space 20 GB (initial size)
Operating System RedHat Enterprise Linux 4 Update 5

Prerequisites

Before starting this tutorial, you should:

.

Have an instance of Oracle WebLogic Server 10.3

.

Have configured a domain

.

Have completed the OBE titled "Configuring Oracle Web Cache for Caching a JavaEE Application"

 

Defining a Second Origin Server

Recollect that one of the prerequisites for performing Web Cache OBEs is that you should have two instances of Web Cache. For these OBEs, we have installed both the instances on the same machine. You have worked on the first instance in the first OBE titled "Configuring Oracle Web Cache for Caching a JavaEE Application." The default origin server for instance 1 is localhost 7780. The default origin server for instance 2 will be localhost 7781 because the instances are on the same machine. In this section you will define the two origin servers and map Oracle Web Cache with the origin servers for load balancing.

 

.

Using the createcomponent command, create a WebCache component within your Oracle instance.

opmnctl createcomponent -componentName WC1 -componentType WebCache

 

.

Using the createcomponent command, create a couple of Oracle HTTP Server components within your Oracle instance.

opmnctl createcomponent -componentName OR1 -componentType OHS

opmnctl createcomponent -componentName OR2 -componentType OHS

 

 

Specify Site Definitions

After you specify site definitions, you create ordered mappings of sites to origin servers.
If you configured multiple origin servers for load balancing, then create one site-to-server mapping that maps all the applicable origin servers to the site.
In that site-to-server mapping, select all the origin servers that apply for the site. If you split the origin servers among multiple site-to-server mappings, load balancing for the site does not occur in the intended manner.

.

Enter the following URL to display Fusion Middleware Control.

http://<hostname>.<domain>:<port>/em

Enter the Oracle Fusion Middleware administrator User name and password. Click Login.

 

 

.

Navigate to the Web Cache Home page in Fusion Middleware Control. Select the Web Cache component, WC1. From the Web Cache menu, select Administration > Origin Servers.


.

If Oracle HTTP Server was installed, the installation process creates a default
site-to-server mapping based on the host name and listening port of Oracle HTTP
Server.
Verify that two origin servers are listed:

Host localhost
Port 7780 and 7781 (the first and second origin server)
Protocol HTTP

 

 

.

Next, create a site-to-server mapping that maps all the applicable origin servers to the site.
In that site-to-server mapping, select all the origin servers that apply for the site.

From the Web Cache menu, select Administration > Sites.

Oracle Web Cache resolves an incoming request first to a site definition, and then to the first matching site-to-origin server mapping.

 

.

The Sites page is displayed. Observe that you have a default site, for example, EDRSR15P1:7779. From the Site-to-Server Mapping section, click Create.

 

.

Enter the following details to configure the Host Pattern, Port Pattern, and Prefix elements:

Element Value
Host Pattern Enter the site pattern, such as www.company.com.
Port Pattern Enter the HTTP or HTTPS port number for the Web site from which Oracle Web Cache is listening for incoming requests.

Select the two origin servers from the Origin Servers section. Click OK.

 

 

.

Click Apply.

 

 

.

Click Web Cache > Control > Restart to restart Oracle Web Cache.

Click Restart to confirm.

Click Close when the restart operation completes successfully.

 

Defining a Ping URL for Application Detection and Origin Server Capacity

Oracle Web Cache detects the availability of the application by sending a user-defined URL to the origin server periodically. If there is no response, then Oracle Web Cache assumes that the origin server is unavailable. The fact that the origin server fails to respond can also mean that there is a problem with the application. Therefore, the Ping URL serves for application detection as well.

.

From the Web Cache menu, select Administration > Origin Servers.

 


.

Select one of the Origin Servers and click Edit.

 


.

In the Ping URL field, enter /benefits. /benefits is a redirect header with zero byte size from the origin server. Because /benefits does not require much resources from the origin server, it is an ideal candidate for ping URL.

.

 


.

For the purpose of this OBE, the load at origin server is expected to be low. To lower the number of maximum concurrent connections that Oracle Web Cache can establish with a particular origin server, change the Capacity to 50. Click OK.

 


.

Repeat steps 2 through 4 for the other origin server (localhost:7781). Restart Web Cache.

Click Restart when prompted for confirmation. Click Close to close the Confirmation window.


Configuring Oracle Web Cache to Use Cookie-Based Sessions

Oracle Web Cache offers three options for session binding mechanism: Cookie-Based, Session Binding IAS, and Internal-Tracking.
The cookie-based session binding mechanism is applicable for all types of Web applications. Oracle Web Cache generates its own cookie to perform session stickiness to the origin servers, so the session stickiness still persists even if the application changes its session ID.
The Session Binding IAS mechanism is used if the application you are trying to cache is based on OC4J. Oracle Web Cache forwards routing information with each request to OC4J through Oracle HTTP Server.
The Internal Tracking mechanism is used if the application does not support cookies or is not OC4J-based. In this case, Oracle Web Cache maintains an in-memory routing table.
In this section, you will configure Web Cache to use cookie-based sessions.

.

Navigate to the Oracle Web Cache Home page. From the Web Cache menu, select Administration > Session Configuration.

.

 


.

The Session Configuration page appears. From the Site list, select the site (for example: EDRSR15P1:7779) to create customized session-bindings.

Click Change the Site to confirm the selection.


.

Scroll down to Session Binding Configuration section. Select Cookie based session binding with any Set-Cookie. Click Apply.

 

.

Restart Oracle Web Cache from Web cache menu > Control > Restart.

Click Restart when prompted for confirmation. Click Close to close the Confirmation window.


Confirming the Configuration for Session Binding


.

Open a browser window and browse the application at http://localhost:7779/benefits. Oracle Web Cache serves the cached pages and forwards any requests to the origin servers.

.

.

 


.

Switch back to the Application Server Control Console browser window. Navigate to Web Cache home page.

 

 


.

In the Origin Servers region, observe that most of the requests are going to only one of the origin servers. Session binding is working correctly.

 

.

Restart Oracle Web Cache from Web cache menu > Control > Restart.

Click Restart when prompted for confirmation. Click Close to close the Confirmation window.

 

 

 

Summary

In this tutorial, you have learned how to:

Resources