Sun ONE Application Server 7, Enterprise Edition Administrator's Guide |
Appendix B
Failover ScenariosThe scenarios in this appendix illustrate how session persistence settings for application server instances and web applications affect the failover of session state in SunTM Open Net Environment (Sun ONE) Application Server 7, Enterprise Edition.
This appendix includes the following topics:
Assumptions and RequirementsThe following information about session persistence is relevant to the scenarios described in this appendix:
- For production environments that require HTTP session persistence and failover capabilities, the only persistence type supported is ha.
- For an application server instance to support session persistence, it has to be enabled for high availability. For more information about enabling high-availability for an application server instance, see "Enabling Availability for an Application Server Instance". In the scenarios described here, it is assumed that high-availability has been enabled for the application server instances.
- For a web application to take part in session persistence, it should be distributable. For more information about distributable web applications, see "Making an Application Distributable". In the scenarios described in this appendix, it is assumed that the web applications are distributable.
- Session persistence configuration for a web application takes precedence over the session persistence configuration for the application server instances on which the web application is deployed.
For more information on session persistence and the configuration settings related to session persistence, see Chapter 18, "Configuring Session Persistence."
Persistence Type Set to memory for Application Server Instances in ClusterSummary
The persistence type for the application server instances in a cluster is set to memory and there are no persistence type settings defined for the web applications deployed in the cluster. If an application server instance on which sessions have been created becomes unavailable, the sessions created on it are not failed over to other application server instances.
Example
Here is an example of the scenario:
- You have set persistence type to memory for all application server instances in the cluster.
- You have deployed a web application with no persistence type settings.
- This web application has serviced requests and sessions for these requests have been created on one or more application server instances.
- An application server instance on which one or more of these sessions were created becomes unavailable.
Result Description
These sessions will not be failed over to other application server instances in the cluster. If requests corresponding to these sessions come in, these requests will be routed to other (available) application server instances in the cluster as per the load balancing algorithm of the load balancer.
Persistence Type Set to memory for an Application Server InstanceSummary
In a development environment, the persistence type for an application server instance is set to memory and there are no persistence type settings defined for the web applications deployed on the instance.
The instance is gracefully shutdown. When the instance restarts, it can recover session state from a file.
This mode is useful when you are using only one application server instance and there is no load balancer. However, in a clustered environment with a load balancer, by the time you have shut down the instance completely and then restarted it, the load balancer may have failed over the session state to other instances in the cluster and the instance may not be able to recover session state when it restarts.
Example
Here is an example of the scenario:
- In a development environment, you have set persistence type to memory for an application server instance.
- You have deployed a web application on the application server instance with no session persistence settings.
- This web application has serviced requests and sessions for these requests have been created on the instance.
- The instance is gracefully shutdown.
Result Description
Before the graceful shutdown, the instance stores the session state in a file in a directory. The path of the directory is the value of the sessionFilename property of session-manager in the server.xml file.
When you restart the instance, it will be able to get the session state from the file.
Persistence Type Set to file for an Application Server InstanceSummary
In a development environment, the persistence type for an application server instance is set to file and there are no persistence type settings defined for the web applications deployed on the instance.
The instance is gracefully shutdown or becomes unavailable. When the instance restarts, it can recover session state from a file.
This mode is useful when you are using only one application server instance and there is no load balancer. However, in a clustered environment with a load balancer, the session state cannot be recovered by any other instance in the cluster. Additionally, while the instance is unavailable, the load balancer may attempt to fail sessions over to other instances, and once the instance restarts, those sessions will have to be re-established (usually requiring the web client to reauthenticate).
Example
Here is an example of the scenario:
- In a development environment, you have set persistence type to file for an application server instance.
- You have deployed a web application on the application server instance with no session persistence settings.
- This web application has serviced requests and sessions for these requests have been created on the instance.
- The instance is gracefully shutdown or becomes unavailable.
Result Description
While the application server instance is available, it stores the information for each session in a corresponding file. The session is stored at intervals specified by the reapIntervalSeconds property of the session manager element in the server.xml file.
If the instance restarts, it will be able to get the information for the sessions from the corresponding files. Because the session state is stored periodically (and not, for example, after every web method), there is a risk of some loss of session data, depending on when the session was last stored.
Persistence Type Set to ha for Application Server Instances in a ClusterSummary
The persistence type for the application server instances in a cluster is set to ha and there are no persistence type settings defined for the web applications deployed in the cluster. If an application server instance on which sessions have been created becomes unavailable, the sessions created on it are failed over to other (available) application server instances in the cluster.
Example
Here is an example of the scenario:
- You have set persistence type to ha for all application server instances in the cluster.
- You have deployed a web application on the cluster with no session persistence settings.
- This web application has serviced requests and sessions for these requests have been created on one or more application server instances.
- An application server instance on which one or more of these sessions were created becomes unavailable.
Result Description
- The load balancer keeps monitoring all application server instances to check if they are available. When the instance becomes unavailable, the load balancer marks the instance as unavailable.
- The load balancer stops sending any unassigned requests to the instance.
- Requests that were sent to the application server instance but that were not serviced are lost and an error is sent to the client.
- All subsequent requests for sessions assigned to the application server instance are failed over to other instances in the cluster.
The instance that was originally serving the requests would have written the session state to the high-availability database (HADB).
If the persistence frequency for this application server instance is set to time-based, the session state is stored periodically at the time interval specified in the reapIntervalSeconds property of the manager-properties element in the server.xml file (for instance-level configuration) or in the sun-web.xml file (for application-level configuration). For more information, see "Configuring Other Session Persistence Properties".
If the persistence frequency for the application server instance is set to web-method, the session state is stored after every web request.
Thus, the persistence frequency setting has a bearing on how up to date is the session state in the HADB at any time.
The application server instances to which the sessions are failed over access the session state from the HADB.
Persistence Type Set to memory for a Web ApplicationSummary
The persistence type for a web application deployed on a cluster is set to memory. If an application server instance on which sessions for this web application have been created becomes unavailable, the sessions created on it are not failed over to other application server instances in the cluster. This will happen regardless of the persistence type setting for the application server instances in the cluster.
Example
Here is an example of the scenario:
- You have deployed a web application with session persistence set to memory.
- This web application has serviced requests and sessions for these requests have been created on one or more application server instances.
- An application server instance on which one or more of these sessions were created becomes unavailable.
Result Description
The result is the same as in the case of "Persistence Type Set to memory for Application Server Instances in Cluster".
Persistence Type Set to file for a Web ApplicationSummary
The persistence type for a web application deployed on a cluster is set to file. If an application server instance on which sessions for this web application have been created becomes unavailable, the sessions created on it are not failed over to other application server instances in the cluster. This will happen regardless of the persistence type setting for the application server instances in the cluster.
Example
Here is an example of the scenario:
- You have deployed a web application with session persistence set to file.
- This web application has serviced requests and sessions for these requests have been created on one or more application server instances.
- An application server instance on which one or more of these sessions were created becomes unavailable.
Result Description
The result is the same as in the case of "Persistence Type Set to file for an Application Server Instance".
Persistence Type Set to ha for a Web ApplicationSummary
The persistence type for a web application deployed on a cluster is set to ha. If an application server instance on which sessions for this web application have been created becomes unavailable, the sessions created on it are failed over to other application server instances in the cluster. This will happen regardless of the persistence type setting for the application server instances in the cluster.
Example
Here is an example of the scenario:
- You have deployed a web application with session persistence set to ha.
- This web application has serviced requests and sessions for these requests have been created on one or more application server instances.
- An application server instance on which one or more of these sessions were created becomes unavailable.
Result Description
The result is the same as in the case of "Persistence Type Set to ha for Application Server Instances in a Cluster".