Configuring Oracle Web Cache for Session Binding and Load Balancing

21
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: 1 . Have an instance of Oracle WebLogic Server 10.3 2 . Have configured a domain 3 . 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. 1 . Using the createcomponent command, create a WebCache component within your Oracle instance. opmnctl createcomponent -componentName WC1 -componentType WebCache Page 1 of 21 Configuring Oracle Web Cache for Session Binding and Load Balancing 11/3/2010 http://st-curriculum.oracle.com/obe/fmw/web_cache/11g/r1/session_bind/session_bind.ht...

Transcript of Configuring Oracle Web Cache for Session Binding and Load Balancing

Page 1: Configuring Oracle Web Cache for Session Binding and Load Balancing

Configuring Oracle Web Cache for Session Binding and Load Balancing

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

Time to CompleteApproximately 30 minutes.

OverviewOracle 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 SpecificationProcessor Type Intel Xeon or Pentium IVProcessor Speed 2.4 GHz or higherNumber of Processors 1 or more (if required)Memory 2 GBHard Disk Space 20 GB (initial size)Operating System RedHat Enterprise Linux 4 Update 5

PrerequisitesBefore starting this tutorial, you should:

1 . Have an instance of Oracle WebLogic Server 10.3

2 . Have configured a domain

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

Defining a Second Origin ServerRecollect 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.

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

opmnctl createcomponent -componentName WC1 -componentType WebCache

Page 1 of 21Configuring Oracle Web Cache for Session Binding and Load Balancing

11/3/2010http://st-curriculum.oracle.com/obe/fmw/web_cache/11g/r1/session_bind/session_bind.ht...

Page 2: Configuring Oracle Web Cache for Session Binding and Load Balancing

2 . 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

Page 2 of 21Configuring Oracle Web Cache for Session Binding and Load Balancing

11/3/2010http://st-curriculum.oracle.com/obe/fmw/web_cache/11g/r1/session_bind/session_bind.ht...

Page 3: Configuring Oracle Web Cache for Session Binding and Load Balancing

Specify Site DefinitionsAfter 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.

1 . 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.

Page 3 of 21Configuring Oracle Web Cache for Session Binding and Load Balancing

11/3/2010http://st-curriculum.oracle.com/obe/fmw/web_cache/11g/r1/session_bind/session_bind.ht...

Page 4: Configuring Oracle Web Cache for Session Binding and Load Balancing

2 . 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.

Page 4 of 21Configuring Oracle Web Cache for Session Binding and Load Balancing

11/3/2010http://st-curriculum.oracle.com/obe/fmw/web_cache/11g/r1/session_bind/session_bind.ht...

Page 5: Configuring Oracle Web Cache for Session Binding and Load Balancing

3 . 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 localhostPort 7780 and 7781 (the first and second origin server)Protocol HTTP

4 . 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.

Page 5 of 21Configuring Oracle Web Cache for Session Binding and Load Balancing

11/3/2010http://st-curriculum.oracle.com/obe/fmw/web_cache/11g/r1/session_bind/session_bind.ht...

Page 6: Configuring Oracle Web Cache for Session Binding and Load Balancing

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

5 . 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.

Page 6 of 21Configuring Oracle Web Cache for Session Binding and Load Balancing

11/3/2010http://st-curriculum.oracle.com/obe/fmw/web_cache/11g/r1/session_bind/session_bind.ht...

Page 7: Configuring Oracle Web Cache for Session Binding and Load Balancing

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

Element ValueHost 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.

Page 7 of 21Configuring Oracle Web Cache for Session Binding and Load Balancing

11/3/2010http://st-curriculum.oracle.com/obe/fmw/web_cache/11g/r1/session_bind/session_bind.ht...

Page 8: Configuring Oracle Web Cache for Session Binding and Load Balancing

7 . Click Apply.

Page 8 of 21Configuring Oracle Web Cache for Session Binding and Load Balancing

11/3/2010http://st-curriculum.oracle.com/obe/fmw/web_cache/11g/r1/session_bind/session_bind.ht...

Page 9: Configuring Oracle Web Cache for Session Binding and Load Balancing

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

Click Restart to confirm.

Page 9 of 21Configuring Oracle Web Cache for Session Binding and Load Balancing

11/3/2010http://st-curriculum.oracle.com/obe/fmw/web_cache/11g/r1/session_bind/session_bind.ht...

Page 10: Configuring Oracle Web Cache for Session Binding and Load Balancing

Click Close when the restart operation completes successfully.

Defining a Ping URL for Application Detection and Origin Server CapacityOracle 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.

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

Page 10 of 21Configuring Oracle Web Cache for Session Binding and Load Balancing

11/3/2010http://st-curriculum.oracle.com/obe/fmw/web_cache/11g/r1/session_bind/session_bind.ht...

Page 11: Configuring Oracle Web Cache for Session Binding and Load Balancing

2 . Select one of the Origin Servers and click Edit.

3 . 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.

.

Page 11 of 21Configuring Oracle Web Cache for Session Binding and Load Balancing

11/3/2010http://st-curriculum.oracle.com/obe/fmw/web_cache/11g/r1/session_bind/session_bind.ht...

Page 12: Configuring Oracle Web Cache for Session Binding and Load Balancing

4 . 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.

Page 12 of 21Configuring Oracle Web Cache for Session Binding and Load Balancing

11/3/2010http://st-curriculum.oracle.com/obe/fmw/web_cache/11g/r1/session_bind/session_bind.ht...

Page 13: Configuring Oracle Web Cache for Session Binding and Load Balancing

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

Page 13 of 21Configuring Oracle Web Cache for Session Binding and Load Balancing

11/3/2010http://st-curriculum.oracle.com/obe/fmw/web_cache/11g/r1/session_bind/session_bind.ht...

Page 14: Configuring Oracle Web Cache for Session Binding and Load Balancing

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

Configuring Oracle Web Cache to Use Cookie-Based SessionsOracle 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.

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

.

Page 14 of 21Configuring Oracle Web Cache for Session Binding and Load Balancing

11/3/2010http://st-curriculum.oracle.com/obe/fmw/web_cache/11g/r1/session_bind/session_bind.ht...

Page 15: Configuring Oracle Web Cache for Session Binding and Load Balancing

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

Page 15 of 21Configuring Oracle Web Cache for Session Binding and Load Balancing

11/3/2010http://st-curriculum.oracle.com/obe/fmw/web_cache/11g/r1/session_bind/session_bind.ht...

Page 16: Configuring Oracle Web Cache for Session Binding and Load Balancing

Click Change the Site to confirm the selection.

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

Page 16 of 21Configuring Oracle Web Cache for Session Binding and Load Balancing

11/3/2010http://st-curriculum.oracle.com/obe/fmw/web_cache/11g/r1/session_bind/session_bind.ht...

Page 17: Configuring Oracle Web Cache for Session Binding and Load Balancing

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

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

Page 17 of 21Configuring Oracle Web Cache for Session Binding and Load Balancing

11/3/2010http://st-curriculum.oracle.com/obe/fmw/web_cache/11g/r1/session_bind/session_bind.ht...

Page 18: Configuring Oracle Web Cache for Session Binding and Load Balancing

Confirming the Configuration for Session Binding

1 . 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.

.

.

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

Page 18 of 21Configuring Oracle Web Cache for Session Binding and Load Balancing

11/3/2010http://st-curriculum.oracle.com/obe/fmw/web_cache/11g/r1/session_bind/session_bind.ht...

Page 19: Configuring Oracle Web Cache for Session Binding and Load Balancing

3 . 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.

Page 19 of 21Configuring Oracle Web Cache for Session Binding and Load Balancing

11/3/2010http://st-curriculum.oracle.com/obe/fmw/web_cache/11g/r1/session_bind/session_bind.ht...

Page 20: Configuring Oracle Web Cache for Session Binding and Load Balancing

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

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

SummaryIn this tutorial, you have learned how to:

Define a ping URL for the application to detect its availability Configure Oracle Web Cache to use cookie-based sessions

ResourcesOracle Fusion Middleware Guide Administrator's Guide for Oracle Web Cache 11g Release 1 (11.1.1)Configuring and Managing Oracle Web Cache eStudyTo learn more about , refer to additional OBEs on the OTN Web site (can link to a specific set of OBEs on the subject)

User CommentsTitle:

nmlkji Post as [email protected] nmlkj Post anonymously

Page 20 of 21Configuring Oracle Web Cache for Session Binding and Load Balancing

11/3/2010http://st-curriculum.oracle.com/obe/fmw/web_cache/11g/r1/session_bind/session_bind.ht...

Page 21: Configuring Oracle Web Cache for Session Binding and Load Balancing

55

66

By submitting a comment, you confirm that you have read and agreed to the terms and conditions.

This feedback form is for tutorial corrections and suggestions. Because of the volume of suggestions, we cannot reply to every comment. In particular:

If you have general questions about this Oracle software product, consult the OTN forums instead.If you are encountering a software problem and need to request support or consulting, file a service request on My Oracle Support.If you want to order hardcopy documentation, go to the Oracle Store.

Submit a new comment (Comments are moderated and will not appear immediately.)

Page 21 of 21Configuring Oracle Web Cache for Session Binding and Load Balancing

11/3/2010http://st-curriculum.oracle.com/obe/fmw/web_cache/11g/r1/session_bind/session_bind.ht...