November 4th, 2009
Chapter 17: Clustering The Need for High Availability Another difficult real-world problem that can be solved via horizontally scaled clustering is the high availability (HA) issue. The challenge here is avoiding situations in which server software/hardware crashes and becomes unavailable. In a regular system, all requests being processed by the server are lost, and all users must wait until the server restarts properly before starting their work from the beginning. For example, if the users are online shoppers in a Web store, they will lose the contents of their shopping carts and any data that they may have entered during the checkout process when the server crashed. This is clearly an unacceptable set of consequences for serious real-world applications. What is desired is a system capable of continuing to handle incoming requests, making a single server crash completely transparent to the end user. The crash and recovery of any individual hardware system should not affect the user experience with the hosted application. Systems with the capability to survive server crashes typically exhibit very high uptime or availability. These systems are called high-availability (HA) systems. Tomcat 6 clusters can be used to implement an HA solution. In this scenario, the following occurs: 1. A request that is destined for the crashed server is redirected to another functioning server in the cluster. 2. The original incoming request is processed by the functioning server. 3. The Tomcat server that failed is logically removed from the cluster, so no further requests will be forwarded to it. 4. When and if the crashed Tomcat server recovers, it is logically added back into the cluster, and once again used to handle incoming requests. The key to enabling this scenario is to realize that any state information maintained by the application in the crashed server (typically, carried in the session) must be somehow made available to the functioning server. Tomcat 6 provides a workable solution to both the scalability and the HA problem. As such, Tomcat 6 has made major inroads in establishing itself as a serious and robust contender for enterprise-level production deployment. To better understand how Tomcat 6 achieves scalability and HA, a few words on some basic clustering concepts are appropriate. Clustering Basics Several basic system design patterns are found in clustered systems (a specific applied instance of the general-distributed computing problem). This section briefly describes two. The preceding discussion in this chapter and Chapter 11 cover a third: the load-balancing frontend pattern. Master-Backup Topological Pattern Figure 17-2 illustrates the master-backup topological pattern. This pattern refers to the way machines are configured and connected to achieve high availability. In this pattern, two (or more) machines are
For reliable and cheap web hosting services please check javaweb hosting website.
Posted in tomcat | No Comments »
November 3rd, 2009
Chapter 17: Clustering Clustering Benefits Clustering in Tomcat 6 enables a set of Tomcat instances on a LAN (called a cluster) to appear to incoming users as a single server. This enables the distribution of work among the servers, called load balancing. Chapter 11 covers a load-balancing configuration with the AJP Connector and mod_proxywith Apache 2.2.x (as well as mod_jkfor Apache 1.3. x and Apache 2.0. x). Figure 17-1 illustrates load-balancing. Without load balancing With load balancing Increasing load from incoming requests Increasing load from incoming requests mod_proxy or mod_jk Apache AJP tomcat1 mod_proxy or mod_jk Apache AJP tomcat2 Overloaded Tomcat server AJP tomcat3 AJP tomcat1 Figure 17-1: Load balancing with Tomcat 6 In Figure 17-1 , if an increasing stream of incoming requests were sent to the tomcat1 server, at some point the server will overload and crash by running out of resources. By deploying a load-balanced cluster, however, more requests can be handled. Scalability and Clustering Using the load-balanced configuration shown in Figure 17-1 , incoming requests are distributed over the tomcat1, tomcat2, and tomcat3 servers. This means that each server is handling only a portion of the incoming requests. If the load-balancing distributor and algorithm are efficient, the system as a whole can handle significantly more requests before overloading. Scalability refers to the capability to provide service for an increasing number of users. Formerly, scaling an application to more users required an upgrade to expensive, multiple-CPU systems and corresponding memory expansion. This approach is often called scaling up. The way that clustering is handled in Tomcat 6 leverages inexpensive high-speed LAN interconnections to share the computing resources of multiple server machines. This approach is called scaling out or horizontal scaling. It provides an obvious cost advantage, as a server farm of low-cost commodity hardware is less expensive than a single multiple-CPU server. Load balancing can solve the scalability problem by enabling the cluster to handle significantly more simultaneous requests than a single nonclustered server. Tomcat servers can support horizontal scaling through the use of the AJP Connector and the mod_jk plug-in with the Apache Web server.
For high quality website hosting services please check cheap web hosting website.
Posted in tomcat | No Comments »
November 2nd, 2009
Clustering The Tomcat server has grown up, from a reference implementation of a Servlet container for demonstrating and testing new APIs to a robust and high-performance Web-tier server. Increasingly, Tomcat is being used in production scenarios to handle real-world Web applications. It is a prime example of a prototype becoming the product. In a sense, the designers and architects realized that their mission changed direction, and they redesigned the Tomcat product for high-stress production deployments. Tomcat 6 is further along the evolutionary path of improved performance. Real-world deployments place many tough demands on the Tomcat server. Many of these requirements were not important to the Tomcat development team when it was a mere reference implementation. Two such areas are support for horizontal scalability (the ability to handle increasing user requests by utilizing a group of physical machines) and high availability (the ability to survive hardware or software failures and maintain a high percentage of application uptime). In other words, what happens when there are so many users that Tomcat servers start to crash, and how can you ensure that no user loses data? These are real-world problems, and Tomcat 6 attempts to solve them by providing built-in support for clustering. Clustering, in this context, refers to running multiple instances of the Tomcat server so that it appears to users as a single server. This chapter covers the many facets of Tomcat 6 clustering, including the following: . Basic principles of clustering . How Tomcat implements clustering . Internal software components that implement Tomcat clustering . Technologies that underlie Tomcat clustering . Various alternative configurations Last but not least, the chapter gives you hands-on experience with configuring and experimenting with this exciting feature of Tomcat. You will be working with three different clustered configurations along the way. As an epilogue, the chapter offers some practical suggestions about clustering that may affect your decision to deploy the technology.
For high quality jboss hosting services please check jboss web hosting website.
Posted in tomcat | No Comments »
November 1st, 2009
Chapter 16: Monitoring and Managing Tomcat with JMX management, administration, and monitoring of a large number of Tomcat servers a requirement that has not been satisfied by Tomcat previously. In Tomcat 6, one beneficial side effect of componentization and the exposure of internal components via JMX is the capability to configure, start, and operate Tomcat from within an external program or script file (external to the JVM running Tomcat). This is known as the embedded mode of operation for Tomcat. Chapter 18 has extensive coverage of this new mode of Tomcat server operation. Before looking at this new mode of Tomcat server operation, however, let s take a look at Chapter 17 , which explores clustering with Tomcat 6.
For reliable and cheap web hosting services please check tomcat web hosting website.
Posted in tomcat | No Comments »
November 1st, 2009
Chapter 16: Monitoring and Managing Tomcat with JMX To enable SSL connections for Tomcat, make sure you set com.sun.management.jmxremote.sslto true, and then follow the instructions in Chapter 14 to set up SSL transport if you have not already done so. On the client machine where you intend to run jconsole over SSL, you should have the server s CA cert in your local keystore and start jconsole with: jconsole -Djavax.net.ssl.trustStore=mykeystore -Djavax.net.ssl.trustStorePassword=mykeystorepassword You should replace mykeystore with the location of your keystore, and mykeystorepasswordwith the password you have set for the keystore. Summary To conclude this chapter, let s review some of its key points: . JMX is a standard for the management of hardware devices, software services, and other manageable entities. The JMX architecture has three levels and each level is componentized. Each level is decoupled from the others. . The bottom level is instrumentation, and it requires that manageable devices and/or services expose their manageable attributes, operations, and events via a set of MBeans. . The top level is distributed services. It involves management applications or higher-level agent functionality and is not well defined at this time. . The middle level is called the agent level. This level aggregates the MBeans from devices and services, and provides a set of services, customized value-added logic, and external/remote access to managed elements. . Tomcat 6 is fully JMX-compliant. It is also fully instrumented. This means that all of its configuration, internal, and runtime components have MBeans associated with them, enabling these components to be accessed through a JMX agent. . The Manager application in Tomcat provides a JMX proxy that can be used to access these Tomcat MBeans. The proxy provides a Web interface for querying the MBean Server, and reading and writing MBean attribute values. This interface, provided through an HTTP protocol adapter, can be used to monitor and manage local as well as remote Tomcat instances. . The jconsole tool included with standard JDK can also be used to monitor and manage Tomcat instances via a user-friendly GUI. jconsole can work with Tomcat instances running on the same machine, or remote instances. . Remote management should be enabled only on internal test networks. If you must enable remote management in production, do so only after careful consideration for security. Specifically, you should enable user authentication and SSL if you must enable remote management for production systems. . One major benefit of Tomcat s JMX support is the capability to consolidate the monitoring and management of Tomcat servers via remote JMX access. Ultimately, this centralizes the
For high quality website hosting services please check java web hosting website.
Posted in tomcat | No Comments »
October 31st, 2009
Chapter 16: Monitoring and Managing Tomcat with JMX Figure 16-16: Remote monitoring for Tomcat via jconsole To enable user authentication and SSL transport, modify the setenv.batfile to contain: set CATALINA_OPTS=-Dcom.sun.management.jmxremote -Djava.rmi.server.hostname=192.168.23.2 -Dcom.sun.management.jmxremote.port=8999 -Dcom.sun.management.jmxremote.ssl=true -Dcom.sun.management.jmxremote.authenticate=true -Dcom.sun.management.jmxremote.password.file=..confpassword.txt -Dcom.sun.management.jmxremote.access.file=..confaccess.txt You can define roles for monitoring and management in the access control file confaccess.txt: monitorRole readonly controlRole readwrite The monitorRole can read only the value of attributes exposed by the manageable components. The controlRole can read and modify any writable attributes. For each role, you need to specify the password in the corresponding password file confpassword.txt: monitorRole monpass controlRole ctrl1@pass
For high quality java hosting services please check tomcat web hosting website.
Posted in tomcat | No Comments »
October 30th, 2009
Chapter 16: Monitoring and Managing Tomcat with JMX Configuring Tomcat for Remote Monitoring For security reasons, the default Tomcat server configuration has remote JMX based monitoring disabled. To enable remote monitoring, edit the setenv.bat file that you ve created in the bin directory to contain the following: set CATALINA_OPTS=-Dcom.sun.management.jmxremote -Djava.rmi.server.hostname=192.168.23.2 -Dcom.sun.management.jmxremote.port=8999 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false Type all of the preceding code on one single line, and be very careful to avoid typos. You need to replace the java.rmi.server.hostname property with your own IP address or host name. On a machine with multiple network connections, you must specify the IP address or host name of the network connection that you are remote managing from. It can be useful to restrict remote management to a specific network connection for example, the internal intranet only. You can also select an available port for use on your specified connection. While the previous configuration allows for remote monitoring, it is wide open and insecure. Anyone can connect to the server over the network, if they know the port, using any JMX client. The previous configuration should be enabled only in a test network and never for production. Please be aware that the Manager JMXProxy is by definition remotely accessible because it works through a browser-based interface. In fact, enabling the Manager application in a production environment is a security risk in itself. See Chapter 14 for more information on disabling the Manager application. To connect and manage the Tomcat server configured previously, on your client machine start jconsole, select Remote Process, and type 192.168.23.2:8999 (replace with your own host name/ip and management port that you have specified). (See Figure 16-6 .) Once connected, you can view all the Tomcat exposed management components and their attributes and modify the value of writable properties. Jconsole works in exactly the same way remotely as it does with local JVMs. When using Windows, Tomcat must be running on an NTFS formatted volume because of a known bug related to file access permissions. Securing the Remote Management Connection with SSL and User Authentication For maximum security, remote management should not be enabled in production. However, if you must enable remote management, you should at least: . Restrict the remote management connection to be within the internal network (or VPN) only . Enable authentication . Enable SSL transport You restrict the remote management connection by specifying the java.rmi.server.hostname property on the Tomcat instance being managed (shown in the last section).
If you looking for unlimited one inclusive web hosting plan please check cheap web hosting website.
Posted in tomcat | No Comments »
October 30th, 2009
Chapter 16: Monitoring and Managing Tomcat with JMX In Figure 16-14 , you will notice that users of the Tomcat server are exposed under the Users key. All the currently active users on the server, including their passwords and role information, are accessible through this jconsole connection. This is clearly a potential security loop-hole. For this reason, remote management and monitoring are disabled by default. The last section of this chapter shows you how to enable remote Tomcat monitoring and management via jconsole. Changing Component Attribute Values via jconsole The writable attributes from the JMX managed component can be changed through the jconsole GUI. As an example, you can change the maxThreads property of the http-8080 threadpool from the default of 150 to 200. In jconsole s MBean tab, look under the Catalina key for the ThreadPool components. Expand the http8080 component s attributes and then click the maxThreads property. You should see the current value of maxThreads, as shown in Figure 16-15 . Figure 16-15: Using jconsole to change the value of attributes on a JMX managed component To change the maxThreads value, simply place the cursor on the current value and then change it. Try changing it from the default 150 to 200. After you ve changed the value, click the Refresh button to confirm that the change has been made.
For reliable and cheap web hosting services please check javaweb hosting website.
Posted in tomcat | No Comments »
October 29th, 2009
Chapter 16: Monitoring and Managing Tomcat with JMX Click the Connect button after selecting the Tomcat JVM. jconsole connects to the Tomcat JVM and displays all sorts of JMX data exposed by the Java VM itself. Locating the Tomcat 6 Exposed MB eans The jconsole displays a lot of exposed metrics courtesy of the fully instrumented JVM. You can find a lot more information about jconsole and the other management and monitoring tools in the JDK by visiting the following URL: http://java.sun.com/javase/6/docs/technotes/guides/management/jconsole.html To locate the MBeans exposed by Tomcat in the jconsole GUI, click the MBeans tab. In this tab, you see JVM MBeans as well as those associated with Tomcat. Those exposed by Tomcat 6 are under the keys named Catalinaand Users. Figure 16-14 shows jconsole with the Tomcat 6 exposed ThreadPool information. Note the http-8080 and jk-8009 threadpools, the same as the one you saw earlier in the Manager JMXProxy example. jconosle just provides a way to access the same set of Tomcat 6 JMX MBeans. Figure 16-14: Tomcat Exposed MB eans viewed through the jconsole utility If you examine the list of exposed manageable elements under the Catalinakey in jconsole, you see that it correspond to the list of JMX manageable elements documented in this chapter. Using jconsole, you can find and monitor the current values of their attributes.
For high quality java hosting services please check java web hosting website.
Posted in tomcat | No Comments »
October 28th, 2009
Chapter 16: Monitoring and Managing Tomcat with JMX Using jconsole GUI to Monitor Tomcat Most administrators create their own script files to perform routine tasks, and the HTML-based access of the Manager application JMX Proxy, as well as the supported Ant tasks, lend themselves well to scripting. For those who would like to monitor and see JMX exposed values in real time, you can use the jconsole utility that is distributed with the JDK since Java 5. The version of jconsole covered in this section is the one distributed with Java SE 6. You must enable the JMX support inside the Tomcat server. To enable this, in the /bin directory, add a file called setenv.bat(or setenv.shin Linux) containing the following line: set CATALINA_OPTS=-Dcom.sun.management.jmxremote You ll need to change the syntax of the environment variable assignment if you are using a Linux shell. If you don t specify the preceding system property, a Java SE 5 jconsole will not be able to connect to Tomcat at all. In Tomcat 6, jconsole can connect to the JVM but does not see any of the Tomcat-exposed MBeans if the preceding system property is not set. Connecting to the Local Running Tomcat Instance With Tomcat 6 running, when you start the jconsole command, you will be prompted to select the JVM to monitor. Look for the local process name of org.apache.catalina.startup.Bootstrap.start. The startup screen for jconsole is shown in Figure 16-13 . Figure 16-13: Attaching to the Tomcat 6 JVM via jconsole
For reliable and cheap web hosting services please check cheap web hosting website.
Posted in tomcat | No Comments »