Home > Articles

  • Print
  • + Share This
This chapter is from the book

This chapter is from the book

Implementing a Failover Mechanism for Your Clustered Servlets and JSPs

A clustered WebLogic Server provides high availability for servlets and JSPs (in the Presentation tier) by transparently replicating client session data contained in HttpSession objects via in-memory replication or file-based or JDBC-based persistence. The following sections discuss each of these HTTP session state failover mechanisms.

In-Memory Replication

With in-memory replication, a primary HttpSession object is created on the clustered managed server to which the client first connects and accesses a servlet or JSP. To support automatic failover for HTTP session states, a clustered managed server replicates the primary HttpSession object in memory to a secondary managed server in the same WebLogic cluster. The replicated HttpSession object is known as the replica or backup HttpSession object. As session data is modified in the primary HttpSession object, the managed server ensures the replica is kept up to date so that it may be used if the clustered managed server that hosts the primary HttpSession object fails.

If the managed server hosting a primary HttpSession object were to fail, the mechanism that a WebLogic cluster uses to provide transparent session state failover is dependent on the type of load-balancing solution that is being used: a WebLogic proxy plug-in or hardware appliance.

In the case of a load-balancing solution that uses a WebLogic proxy plug-in and client-side WebLogic Server cookies, the proxy plug-in uses the cookie information to automatically redirect subsequent HTTP requests to the clustered server hosting the replica HttpSession object. The replica HttpSession object is then upgraded to the primary HttpSession object, and a replica HttpSession object is created on another managed server in the WebLogic cluster. In the HTTP response, the proxy server updates the client's cookie to reflect the new primary and secondary servers as a safeguard for subsequent HttpSession object failovers.

NOTE

If URL rewriting is used, the proxy server extracts the session ID and the primary and secondary HttpSession object servers from the inbound client URL.

In the case of a load-balancing solution that uses a hardware appliance, the primary and replica HttpSession object locations in a cookie or URL serve only as a history for a client's session state locations. Because the hardware appliance will redirect the failed HTTP request to any available managed server in a WebLogic cluster based on a certain algorithm, the WebLogic cluster uses the replica to create a new primary HttpSession object on the newly targeted managed server. Hence, the replica HttpSession object remains as the replica. The new information about the primary HttpSession object location is updated in the client's cookie, or via URL rewriting.

Configuring In-Memory Replication

The type of session state persistence you are going to implement is specified in the WebLogic Deployment Descriptor (weblogic.xml) file for a deployed Web application via the PersistentStoreType parameter. To specify in-memory replication for a Web application, edit the weblogic.xml file using an XML editor and set the value of this parameter to replicated as follows:

<session-descriptor>
 <session-param>
  <param-name>PersistentStoreType</param-name>
  <param-value>replicated</param-value>
 </session-param>
</session-descriptor>

TIP

You can also use the Administration Console to modify the weblogic.xml file for a deployed Web application.

Configuring Replication Groups to Specify Replica Object Servers

When a primary HttpSession object is created, it is the responsibility of the hosting managed server to rank other managed servers within the same WebLogic cluster to determine which server will host the replica HttpSession object. By default, a managed server will attempt to create the replica HttpSession object on a different machine than the one that hosts the primary HttpSession object.

Through the configuration of replication groups, however, you can influence the location of the replica HttpSession objects. A replication group is a list of clustered managed servers within the same WebLogic cluster that serve as preferred locations for replica HttpSession objects.

You can use the Administration Console, as shown in Figure 25.19, to assign a clustered managed server to

  • A replication group, which defines a preferred logical group of clustered managed servers for hosting the replica HttpSession objects

  • A preferred secondary group, which defines a secondary logical group of clustered managed servers that can be considered for hosting the replica HttpSession objects

How a managed server ranks other managed servers in a WebLogic cluster is described in Table 25.2.

Figure 25.19Figure 25.19 Configuring replication groups using the Administration Console.

Table 25.2 The Ranking Rules for Selecting a Host for a Replica HttpSession Object

Server Rank

Managed Server Resides Physically on Another Machine

Managed Server Is a Member of the Preferred Replication Group

1

Yes

Yes

2

No

Yes

3

Yes

No

4

No

No


Using the rules described in Table 25.2, the primary managed server ranks other members of the cluster and selects the highest-ranked server to host the replica HttpSession object.

Demonstrating the In-Memory Replication of Session State

The quickest way to verify whether your WebLogic cluster is providing session state failover using in-memory replication in conjunction with your load-balancing solution is to build and deploy the inmemrep Web application, which comes bundled with WebLogic Server if you opted to install the WebLogic Server examples during the server's installation process.

NOTE

You need to install the WebLogic Server examples to deploy the inmemrep Web application code.

The following steps describe how to build and deploy the inmemrep Web application to the WebLogic cluster (mycluster) you configured earlier in this chapter:

  1. Open a new command shell and set up your WebLogic environment by executing the setEnv command from the root of your domain's (objectmind) directory.

  2. Change directories to the following:

  3. %wl_home%\samples\server\src\examples\cluster\sessionrep\inmemrep
  4. Use the build script to compile the Web application by executing the ant command. This process builds both the JSP and deployment descriptors and packages them in a WAR file named InMemRepClient.war.

  5. From the Administration Console, click the Application link under the Deployments node in the left pane and click the Configure a New Application link.

  6. Use the links at the bottom of the page to navigate to the location of the InMemRepClient.war file and click the Select link next to the InMemRepClient.war filename.

  7. Select the cluster that was previously created (mycluster) as your target for deployment and click Configure and Deploy.

When the InMemRepClient Web application is deployed, you can access it by navigating to the following URL in a Web browser:

http://ip_address_of_proxy:port_of_proxy /InMemRepClient/Session.jsp.

You can add some values to the JSP, as shown in Figure 25.20, and bring down the clustered server from which you just requested the JSP. Now you can refresh the browser to demonstrate in-memory session persistence. You will notice the session is now hosted on another machine.

Figure 25.20Figure 25.20 The InMemRepClient Web application demonstrating in-memory session persistence.

File-Based Persistent Storage

File-based persistence implies that you will be using a system directory to store all the session information related to your Web application. The requirements for using this type of session persistence mechanism are as follows:

  • The system directory must be shared and available to each managed server in the WebLogic cluster.

  • You must have enough disk space to store the session information (the number of valid sessions multiplied by the size of each session).

To specify file-based persistent session storage for a Web application, edit the associated weblogic.xml file using an XML editor and set the value of the PersistentStoreType and PersistentStoreDir parameters as follows:

<session-descriptor>
 <session-param>
  <param-name>PersistentStoreType</param-name>
  <param-value>file</param-value>
  <param-name>PersistentStoreDir</param-name>
  <param-value>your_shared_folder_name</param-value>
 </session-param>
</session-descriptor>

Here, your_shared_folder_name specifies the directory path where the clustered managed servers will write and retrieve their respective session's data.

Using the file-based persistence approach allows all managed server instances in a WebLogic cluster to have access to all the generated session data. Hence, client HTTP requests can be serviced by any managed server in a WebLogic cluster. The HttpSession object can fail over to any clustered server in a WebLogic cluster and still have access to its session state data.

However, there is a significant reduction in the WebLogic cluster's performance using this approach because session state is continuously being written to the disk system, and session data needs to be retrieved from the disk upon session failover. Also, an added concern is that if you lose the disk system where the session is persisted, you also lose all your session data.

JDBC-Based Persistent Storage

JDBC-based persistence is similar to file-based persistence because it also allows all managed server instances in a WebLogic cluster to have access to all the generated session data, with the exception that the session data is now persisted to database instead of a file system. The advantage of using a database for storing persistent session storage is that you can leverage the high-availability, scalability, and high-performance features of a database to safeguard as well as provide performance-based writing and retrieval of session data. However, this method of session persistence is still not as fast as in-memory replication.

To specify JDBC-based persistent session storage for a Web application, follow these steps:

  1. Create a table named wl_servlet_sessions in the database using the column and data type information described in Table 25.3.

  2. Table 25.3 The Column and Data Type Information for the wl_servlet_sessions Table

    Column Name

    Data Type

    wl_id (primary key)

    Variable-width alphanumeric column, up to 100 characters

    wl_context_path (primary key)

    Variable-width alphanumeric column, up to 100 characters

    wl_is_new

    Single-character column

    wl_create_time

    20-digit numeric column

    wl_is_valid

    Single-character column

    wl_session_values

    Large binary column

    wl_access_time

    20-digit numeric column

    wl_max_inactive_interval

    Integer column


  3. Assign a connection pool that has read/write permissions to the wl_servlet_sessions database table to your WebLogic cluster.

  4. Assign the connection pool's associated data source to the same cluster.

  5. Edit the associated weblogic.xml file using an XML editor and set the value of the PersistentStoreType and PersistentStorePool parameters as follows:

  6. <session-descriptor>
     <session-param>
      <param-name>PersistentStoreType</param-name>
      <param-value>jdbc</param-value>
      <param-name>PersistentStorePool</param-name>
      <param-value>Connection_Pool_Name</param-value>
     </session-param>
    </session-descriptor>

    Here, Connection_Pool_Name specifies the JDBC connection pool to be used for persistence storage.

CAUTION

When connection pools are targeted to a WebLogic cluster, the number of database connections will be multiplied, because the connection pool will exist on each managed server in the cluster.

  • + Share This
  • 🔖 Save To Your Account

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020