Chapter 2. Distributed Session Servers

Table of Contents

2.1. Overview
2.2. Basic Concepts
2.3. Server Structure
2.4. Server Process
2.5. Duplicate Login Prevention
2.6. Clustering
2.7. Session Server Configuration
2.8. Session Clustering
2.9. Configuration Changes in JEUS 7 from JEUS 6
2.9.1. JEUS 6 Configuration
2.9.2. JEUS 7 Configuration
2.9.3. JEUS 6 Central Session Server Support

This chapter describes the structure, operation, and configuration of distributed session server that are used for session tracking in clustered environments.

Session servers are used to manage or back up client session data. They are especially useful when managing session data from multiple web servers and servlet engines in a clustered environment.

In JEUS 7, distributed session servers are used to manage session data.

Note

Prior to JEUS 7, central session server was used in general. Due to problems with centralized management of the system, only distributed session servers are used in JEUS 7.

Distributed session servers provide session clustering with enhanced scalability and safety. They enhance performance in a large scale clustered environment.

Distributed session servers have the same basic functionality as the central session server. In a clustered environment with many servlet engines, they allow sessions to persist even if a sequence of requests from the same client is not handled by the same servlet engine.

Distributed session servers mean that the managing agents of the sessions are distributed which provides high degree of scalability.

The following is a summary of distributed session server's characteristics.

  • It is possible to persist sessions in a clustered environment composed of many servlet engines.

  • Even if the servlet engine fails while processing a request, other servlet engines can continue to process the request without losing the session.

  • Scaling is easy because of the distributed protocol.

Distributed session servers use a distributed structure in which the servers that manage session objects are distributed to each servlet engine (web engine) or EJB engine.

When using distributed servers, a separate distributed session server exist in each engine of the cluster, and they provide continuous services by communicating with other distributed session servers.

The following diagram shows the session clustering structure with four web engines.


The arrows in the previous structure map represent possible socket connections between the distributed session servers. Instead of having all sockets always be connected to each other, they connect and maintain the connection only when they need to communicate with other engines in order to maintain a session.

The following diagram shows the internal structure of a distributed session server, which is a subcomponent of the web engine.


By default, distributed session servers use session routing. Session routing attaches the name of a specific session server to the session ID so that it knows which server contains the session data. Performance is enhanced when session routing is used.

Web servers that support session routing route requests to the web engine that contains the required session object. Session routing works in the same way for distributed session servers. For additional information, refer to "1.3.2. Session Tracking in Clustered Environments".

A session key is used for distributed session servers that use session routing.

The following example shows a session key being used in a web engine.

<SessionID>.<primary-engine-name>
   Example) XXX.domain1/server1

ValueDescription
XXXSession ID. The actual session ID is a random string that is longer in length.
domain1/server1Routing information. A servlet engine named domain1 is used.

Each engine is assigned a session routing ID for session routing that identifies the web engine when it connects to the web server. The session routing ID is automatically created according to its configuration. For the three web engines in [Figure 2.3], it is assumed that the session routing ID and back up server's session routing ID are assigned as follows:

  • Web engine (server1)

    • Session routing ID: domain1/server1

    • Session routing ID of the backup server: domain1/server2

  • Web engine (server2)

    • Session routing ID: domain1/server2

    • Session routing ID of the backup server: domain1/server3

  • Web engine (server3)

    • Session routing ID: domain1/server3

    • Session routing ID of the backup server: domain1/server1

The following diagram shows the failover structure of session tracking that uses the session routing ID assigned to each distributed session server.


The following describes the failover structure in [Figure 2.3].

  1. The web server checks the session routing ID and attempts to send the request to web engine server1, but server1 has failed.

  2. The web server arbitrarily selects a different web engine and sends the request. In this example, server3 is selected.

    server3, which received the request from the web server, checks the session routing ID and determines that server1 contains the session object for the request, and that the backup exists in server2.

  3. server3, which is a distributed session server, attempts to retrieve the session object by connecting to server1, but the request fails due to the failure of server1.

  4. Because the request failed, server3 attempts to connect to the backup server, server2. Server2 returns the backup of the requested session object to server3.

  5. Server3, which has successfully retrieved the session object, processes the client request and sends the response message to the client. A new session key is created and sent, the client's session key is modified, and future requests are forwarded to server3. When a new session key is created, only the session routing ID is changed.

Web servers cannot provide session routing in situations where the request cannot be sent because the web engine has failed or there is no connection to the target web engine.

The following describes [Figure 2.3] for distributed session servers where session routing is not used.

  1. Without session routing, the session ID does not exist. The web server tries to send a request to an arbitrary web engine. In this example, web engine server1 is selected.

  2. The web server detects that server1 has failed and selects another web engine, server3, and sends the request again.

  3. Because server3 does not know the routing information of the session, it sends a request to the currently connected distributed session server, server1, but the attempt fails.

  4. The distributed session server sends the request to server2, and server2 returns the session.

  5. Server3, which received the session, sends the unmodified session key to the client. As a result, the next request may not be sent to server3 that contains the session.

    Note

    For explanation purposes, the routing information was written out as 'domain1/server1' but, this information is encoded during operation.

This section describes duplicate login prevention function that is newly added to distributed session servers.

Distributed session servers provide duplicate login prevention function that include the basic duplicate login management functions provided by applications.

Duplicate login prevention of distributed session servers prevents duplicate login using a single application ID. When the same ID is used to log into two different sessions, the existing session is removed to prevent duplicate login.

To prevent duplicate login, the login manager is configured similar to the existing central session server. A server that stores the login information is specified among the servers in the cluster, and a secondary server is configured to prepare for failure.

Duplicate login prevention can be configured for each application and login information is managed per application. The <use-jeus-login-manager> setting must be set to true in jeus-web-dd.xml.


The following is description of [Figure 2.4].

  1. Client A using SessionA tries to log into Web EngineA with the ID, UserA.

  2. Web EngineA registers the login information in the Login Manager.

  3. The Login Manager sends ACK for the login to Web EngineA.

  4. Web EngineA sends a response to Client A.

  5. Client B that is using SessionB tries to log into Web EngineB with the ID UserA.

  6. Web EngineB registers login information in the Login Manager.

  7. The Login Manager detects a duplicate login.

  8. The Login Manager tells Web EngineA to discard the existing session SessionA and Web EngineA deletes the session.

  9. The Login Manager sends ACK for the login to Web EngineB.

  10. Web EngineB sends a response to Client B.

Note

Since login event occurs in an application, methods for sending a login event from the JEUS Login Manager are limited. Jeus Login Manager recognizes a login event when the setAttribute is executed with the "JEUS_LOGIN_KEY". This value can be changed to "jeus.application.login.key" in jeus-web-dd.xml. Logout can be executed by using removeAttribute with the same key. Invalidated sessions are logged out automatically.

Multiple servers can share and use session data when distributed session servers form a cluster.

The following are the steps for creating a cluster in the WebAdmin.

Note

Since distributed session servers are automatically clustered, the configuration is applied dynamically, but non-clustered session servers may need to be restarted.

The following are the steps for configuring distributed session servers in the WebAdmin.

  1. Click [Clusters] from the left menu of WebAdmin to go to the cluster search screen. In the clusters list, click the desired cluster and then open the [Session Router Config] tab.

  2. Click [Lock & Edit] to change to the configuration mode.

  3. Configure each item on the Session Router Config screen and press [OK]. To reset the configuration, click [Reconfiguration], and to delete the configured value, click [Delete].


    The following describes each property.

  4. Complete the session configuration and click [Apply Changes] to apply the changes.

  5. The changes are applied and the following result message is displayed. The server must be restarted to apply the configuration changes on the Session Router Config screen.

This section describes session clustering.

In session clustering which includes basic clustering provided by JEUS, an application decides which session clustering it belongs to regardless of the server configuration. An application is deployed by selecting a session clustering and the session is maintained and managed in the cluster.

Except the clustering scope, the internal operation of session clustering is same as distributed session server. Session clustering allows session sharing between clusters, and each server can configure multiple session clusterings.

The following shows an example of configuring session clustering. Triangles, circles, and stars represent applications.


  • Server1 and server2 are tied to Server Cluster1.

  • Server3 and server4 are tied to Server Cluster2.

  • When an application is deployed to JEUS server cluster, the same application must exist in the cluster.

    • ApplicationA and C: server1 and server2

    • ApplicationB and D: server3 and server4

  • ApplicationA and ApplicationB are maintained and managed in each clustering through distributed session server clustering.

  • ApplicationC and ApplicationD can be shared beyond the cluster through session clustering of distributed session servers. Sessions are maintained and managed on all servers, server1, server2, server3, and server4.

Using session clustering as in the previous example allows various application configurations beyond the limits of the existing clustering.

Note

A common URL between applications is needed in order to share a session among different applications. This is not a restriction of JEUS but that of the browsers or cookies. Applications using session clustering must have a common URL configured to the session cookie path.

Using WebAdmin

The basic configuration for session clustering is the same as distributed session server configuration. Following are the steps for configuring session clustering in the WebAdmin.

Note

Since session clustering is a structure that determines session clustering in the application, a session cluster must be selected and configured in jeus-web-dd.xml.

This section describes the configuration changes between JEUS 6 and JEUS 7 using the four clustered servers from the example in [Figure 2.1].

The following are the differences between distributed session servers in JEUS 6 and JEUS 7.

  • In JEUS 6, each node requires a configuration file because distributed session servers can be configured using the node clustering system. However, in JEUS 7, since sessions are part of the cluster, the configuration is performed at the cluster level.

  • The manual backup configuration, <session-router>, has been removed from JEUS 7. Backup is now automatically configured through the GMS system.

  • In JEUS 6, each session thread pool is configured separately. In JEUS 7, the thread pools are unified and configured using the Reserved Thread Num option.

Note

The user must understand the concepts of the node and container used in JEUS 6 as well as that of the server used in JEUS 7. Server1 and server2 can be considered similar to container1 and container2 in JEUS 6. What was previously called a container in JEUS 6 is now called a server. The names of the nodes are MyNode and MyNode1.

The following shows an example of a distributed session server configuration in JEUS 6.

[Example 2.1] JEUS 6 Configuration: <<JEUSMain.xml>>

<jeus-system>
     . . .
    <node>
        <name>MyNode</name>
        <engine-container>
            <base-port>3030</base-port>
            <name>container1</name>
            <engine-command>
                <type>servlet</type>
                <name>engine1</name>
            </engine-command>
           . . .
        </engine-container>
        <engine-container>
            <base-port>3031</base-port>
            <name>container2</name>
            <engine-command>
                <type>servlet</type>
                <name>engine2</name>
            </engine-command>
        </engine-container>
        . . .
        <session-router-config>
            <session-router>
                <!-- Uses the full name which the node name, engine, and engine name are mixed together.-->
                <engine-name>MyNode_servlet_engine1</engine-name>
                <!-- When a particular backup is not desired,even when there's no configuration, it is automatically selected. -->
                . . .
            </session-router>
          <session-router>
                <!-- Uses the full name which the node name, engine, and engine name are mixed together.-->
                <engine-name>MyNode_servlet_engine1</engine-name>
                <!-- When a particular backup is not desired,even when there's no configuration, it is automatically selected. -->
            </session-router>
        </session-router-config>
            . . .
    </node>
    . . .
    <node>
    <name>MyNode1</name>
        <engine-container>
            <base-port>3033</base-port>
            <name>container1</name>
            <engine-command>
                <type>servlet</type>
                <name>engine1</name>
            </engine-command>
            . . .
        </engine-container>
        <engine-container>
            <base-port>3034</base-port>
            <name>container2</name>
            <engine-command>
                <type>servlet</type>
                <name>engine2</name>
            </engine-command>
            . . .
        </engine-container>
        . . .
        <session-router-config>
        . . .
          <session-router>
                <!-- Uses the full name which the node name, engine, and engine name are mixed together.-->
                <engine-name>MyNode_servlet_engine1</engine-name>
                <!-- When a particular backup is not desired,even when there's no configuration, it is automatically selected. -->
                . . .
          </session-router>
          <session-router>
                <!-- Uses the full name which the node name, engine, and engine name are mixed together.-->
                <engine-name>MyNode_servlet_engine1</engine-name>
                <!-- When a particular backup is not desired,even when there's no configuration, it is automatically selected. -->
                . . .
          </session-router>
        </session-router-config>
        . . .
    </node>
    . . .
</jeus-system>


JEUS 7 allows the existing structure of JEUS 6 to be maintained and operate in JEUS 7 for those who are unfamiliar with the domain structure of JEUS 7. The JEUS 6 structure here means the deploy format as in the following example.

  • There are two nodes and each one creates two containers.

  • A separate application is deployed to each container. A total of four applications exist each on a separate container.

  • Sessions can be shared in the same node by setting the <shared> option, or they can be shared among different nodes using a central session server.

  • As a result, all sessions in the four containers are shared.

This method does not work with JEUS 7. JEUS 7 session servers use clusters by default, and different applications cannot be deployed to each server in the cluster. In other words, to deploy different applications on each physical server, the servers cannot belong to a cluster. JEUS 7 provides Http Session Config to allow servers to share sessions without being in a cluster.

Note

The aforementioned session clustering cannot be used with Http Session Config. This feature overrides the session clustering configuration.

However, Http Session Config is a configuration that is not compliant with the domain structure specification. It is provided for user convenience and the following restrictions must be considered for use.

  • Http Session Config only applies to web applications, not EJBs.

  • If clustering is also configured, the clustering configuration is ignored.

  • The configuration is set in domain.xml and applies to every server in the domain. It is not possible to configure individual servers.

  • The <shared> option is set to true which forces every application on every server to share the sessions.

The following are the steps for configuring Http Session Config in the WebAdmin.