Chapter 17: Clustering The second item is the
Chapter 17: Clustering The second item is the major benefit delivered by the in-memory session replication scheme. The other schemes examined thus far cannot deliver this benefit. However, with the benefit comes substantial cost. Here are the items of concern for this approach: . The traffic on the interconnection (usually a LAN) can quickly become very heavy, especially when you are using DeltaManager, where changes to all sessions are sent to all members of the group. . Sessions are not persistent. This means that this model assumes that the overall system operates continuously (sometimes called 24/7 or nonstop operation). All sessions are lost if the entire cluster is shut down. This is not the case with persistent session management. . Configuration, tuning, and maintenance can be quite complex. The remaining sections in this chapter cover each of the clustering mechanisms in more depth, and provide hands-on configuration with working examples. Working with Tomcat 6 Clustering As discussed earlier, a Tomcat 6 clustering implementation depends on a load-balancing frontend and a session-sharing backend. The load-balancing frontend may implement sticky sessions (using Apache mod_proxyor mod_jk), which ensure that the same clustered Tomcat 6 instance will always handle the same session. Taking a peek under the hood reveals why this is very important in several clustering configurations. Session Management in Tomcat 6 Sessions are created and managed by the Tomcat 6 container during application execution, and are made available to JSP and servlets via the application context. In a single-server instance, Tomcat 6 sessions are objects (which can contain and reference other objects) that are kept on behalf of a client. Because the HTTP protocol is stateless, there is no simple way to maintain application state using the protocol alone. For example, consider a shopping cart application. Each product page accessed by a user comes into the server as a separate and distinct HTTP request. There is no way for the server to match up independent incoming requests that represent an application flow. However, most Web applications need to maintain state information associated with a user (for example, the items in the user s shopping cart). A server-side session is the main mechanism used to maintain state. It works as follows: 1. The server writes a cookie to the user s browser instance. The cookie contains a token to retrieve the server-side session (data structure). 2. The cookie is supplied by the browser instance every time it accesses a page on the site. 3. The server reads the token in the cookie to extract the corresponding session. An analogy to a session is the coat check tag that one may obtain prior to entering a theatre or concert. In this case, the cookie is the tag (smaller and simpler to carry) and the session is the coat (larger, but important data that is kept on the server side). You, the client, hold the tag and return the tag for the
For reliable and cheap web hosting services please check tomcat web hosting website.