Archive for July, 2007

210 CHAPTER 8 HIGH-PERFORMANCE DEPLOYMENTS If

Sunday, July 22nd, 2007

210 CHAPTER 8 HIGH-PERFORMANCE DEPLOYMENTS If the Web tier can return the response without interacting with the business tier, then it does not disrupt requests that require business tier interactions. In hybrid environments with both Web and non-Web clients, the business tier can have multiple entry points. You do not want your non-Web clients needlessly affecting the performance of the Web tier. The business tier also manages data persistence through the data persistence scheme that you choose. Regardless of the implementation, your business objects will undoubtedly need to interact with a transactional data object model. There is a distinct logical separation between business logic objects and business data objects, but they are so tightly coupled in practical implementations that physically separating them into their own tiers usually degrades performance beyond any benefit you might gain by separating them. Finally, the persistent data stores represent your databases and legacy systems. These are implemented by anything that provides storage and retrieval capabilities. In any production deployment, you should strive to physically separate data stores from your application business tier. Consider the impact of interrupting your business processing with the movement of a read/write head on your hard drive to seek an additional block of data, or the impact of re-indexing a table. Databases are well optimized to perform these operations, but not on the same machine that is running your application server. The best deployment strategy is to separate each tier into distinct application server instances, which may or may not reside on the same physical machine. Furthermore, it is best to have multiple application server instances working together to satisfy requests to each tier. Figure 8-2 shows this deployment strategy. Figure 8-2. Deploying multiple application server instances to service each logical tier As you can see in Figure 8-2, each logical tier can be serviced by multiple application server instances. This has two benefits: More servers can service more load. Availability is enhanced. If one instance goes down, then its load can be redistributed across the remaining instances. The physical separation of tiers introduces some additional complexity in tuning because as you increase the number of thread pools, you introduce additional wait points. But as you tune your environment, you will learn that this separation actually provides much greater control
If you are searching for cheap webhost for your web application, please visit MySQL5 Web Hosting services.

CHAPTER 8 HIGH-PERFORMANCE DEPLOYMENTS Formal Deployment Topology (Make web site)

Sunday, July 22nd, 2007

CHAPTER 8 HIGH-PERFORMANCE DEPLOYMENTS Formal Deployment Topology Most high-performance deployments configure multiple application server instances to service their requests, and place a load balancer between the application servers and the users to distribute requests appropriately. In some cases, this configuration is adequate, but in the context of best practices and defining the optimal deployment methodology I am promoting, this section defines the various logical tiers that compose an enterprise Java environment. Feel free to combine logical tiers into single units when appropriate to your environment. Figure 8-1 shows a breakdown of the logical tiers that make up an enterprise Java environment. Figure 8-1. An enterprise Java environment contains a static Web tier, a dynamic Web tier, logical business tiers, and back-end persistent data stores. Figure 8-1 shows the logical separation of functionality into the following tiers: Static Web tier Dynamic Web tier Business tier(s) Persistent data stores The static Web tier is facilitated by your Web server. This tier is responsible for serving static content such as HTML pages, style sheets, and images. A request for a static resource should not disturb the rest of your environment and hence should be allocated its own resources. If the request requires dynamic Web content, then it can be forwarded to the next tier. The dynamic Web tier holds all of your servlets and JSPs. Its purpose is to generate dynamic responses based upon the nature of a request. If it can serve its content from either a cached resource or a direct computation, then it can return the response directly to the user. Otherwise, it forwards the request to the appropriate business tier. The business tier is responsible for implementing business logic and managing data persistence. There are two reasons to provide it with its own resources:
Visit our web design programs services for an affordable and reliable webhost to suit all your needs.

208 CHAPTER 8 HIGH-PERFORMANCE DEPLOYMENTS (Web design programs) understanding of

Saturday, July 21st, 2007

208 CHAPTER 8 HIGH-PERFORMANCE DEPLOYMENTS understanding of your application and application server capabilities, and the next step is to plan your deployment. Depending on the nature of your application and the requirements of your business, the deployment can be simple or extremely complex. You should consider the following three criteria when planning your deployment strategy: Expected user load Availability requirements Failover requirements Your expected user load dictates the hard requirements for the minimum number of hardware and software servers you need, which is closely related to the results of your capacity assessment. Note, however, that if one server can service 500 simultaneous users, it does not necessarily follow that two servers can service 1,000 simultaneous users. Other variables (discussed later in this chapter) complicate the math ever so slightly. You should next determine your application s availability requirements, or the percentage of time your application needs to be functional. For example, an e-commerce site s availability requirements are extremely high. This type of site may demand 99.99 percent availability, meaning that the maximum tolerable downtime is approximately 53 minutes per year. An intranet application may have much looser requirements: it might be used every day from 8:00 AM to 5:00 PM, which facilitates easy application server restarts in the evening when necessary. Furthermore, if the intranet application is not available, a simple restart may be adequate. These are the two extremes, and your organization probably falls somewhere between them. Keep your availability requirements in mind as you read through this chapter. Failover requirements are slightly different from availability requirements. Availability requirements dictate how much of the time your application needs to be available, whereas failover requirements define the impact of application server outages on your users. As you will see later in this chapter, you can configure multiple application servers inside the context of a cluster to behave as one logical unit, and when one instance goes down, its traffic can be redistributed across the remaining servers. But failover begs the question, How is the user impacted? Is this transition from one application server instance to another seamless to the user, or is the user required to log on to the system again and start work over? While the former case is obviously ideal, it can significantly impact application performance, so you need to evaluate this requirement against your business requirements. In the previous example, an e-commerce company may be required to make the transition seamless. Consider what you would do if you connected to your favorite e-tailer, browsed for an hour, put 15 items into your shopping cart, and then unexpectedly all of your selections were lost. Would you feel confident in this vendor? Price notwithstanding, would you continue to frequent this e-tailer s site? In the intranet example, asking users to log on again may be acceptable, but clearly the same does not hold true for an e-commerce site. Again, it all depends on your business requirements. The purpose of this chapter is to equip you with the knowledge to configure your hardware and software environments to best suit your users requirements. To this end, we ll examine your high availability and failover requirements to determine the best performing deployment.
Please visit Domain Name Hosting services for high quality webhost to host and run your jsp applications.

CHAPTER 8 (Web site developers) High-Performance Deployments There s

Saturday, July 21st, 2007

CHAPTER 8 High-Performance Deployments There s still one thing that I don t understand, said John, with a gleam of concern in his eyes. What s that? I asked. Well, I can tune my application and my application server, but how do I deploy them? I have heard some people say that I need to scale my application and other people say that I need to cluster it. They mention vertical and horizontal scaling and clustering. What is best? And, most important, how do I do it? While John s tone was inquisitive, I could sense his frustration with the amount of outside information he was being fed. Deployments can be tricky, I replied. John had touched on a point that I hold very close to my heart, as I have been burned before by faulty deployments the best application can be brought to its knees if the deployment is faulty. First off, while scaling and clustering are related, they are not mutually exclusive. Scalability is governed by your availability requirements: you scale based upon the percentage of the time you need your application available to your users. Clustering, on the other hand, is governed by your failover requirements: you cluster based upon the way your users are affected by application server outages. Next, vertical scaling and clustering refers to installing multiple application server instances on a single machine, while horizontal scaling and clustering refers to installing multiple application server instances on multiple machines. Again, scaling and clustering are not mutually exclusive, and the best choice is usually a combination of the two. Let me walk you through the details . . . Deployment Overview When developing an application according to the methodology presented in this book, you choose the optimal design patterns to meet your business requirements; introduce performance criteria into use cases; iteratively test the performance of your components in unit testing, integration testing, and production staging testing; and perform a capacity assessment to understand what load your application can reasonably support and specifically how your environment responds when that load is exceeded. Meanwhile, you tune your application and application server using the wait-based tuning approach to uncover both application and application server bottlenecks. Finally, you harden your application servers to maximize request throughput and move waiting requests to the most appropriate location. At this point, you have a good
We recommend you use shared web hosting services, because many users agree that it is cheap, reliable and customer-satisfying webhost.

206 CHAPTER 7 TUNING AN APPLICATION (Medical web site) SERVER

Saturday, July 21st, 2007

206 CHAPTER 7 TUNING AN APPLICATION SERVER requirements, it identified tuning configuration parameters and weighted their significance in terms of performance impact. I proposed that for the majority of Java EE applications, 80 percent of their performance capabilities can be met by tuning the following four parameters: heap configuration, thread pools, connection pools, and caches. Finally, we turned our attention to the remaining 20 percent of fine-tuning options, including sizing EJB pools, precompiling JSPs, tuning JMS parameters, understanding servlet pooling, tuning prepared statement caches, and configuring advanced JDBC options. In the next chapter, we look toward high-performance deployment options and answer the following questions: How do you scale a tuned application server instance? Should you implement clustering? How should you lay out your hardware? And how should you separate your logical tiers?
From our experience, we are can tell you that you can find a reliable and cheap webhost service at Java Web Hosting services.

CHAPTER 7 TUNING AN APPLICATION (Web design conference) SERVER A

Friday, July 20th, 2007

CHAPTER 7 TUNING AN APPLICATION SERVER A dirty read occurs when a transaction is allowed to see uncommitted changes to data, for example, if a change is made to data inside one transaction that is visible to other transactions before the changes are committed to the database. A dirty read means that if the transaction modifying the data rolls its transaction back and reverts the data back to its state before it started, then other transactions may be operating against incorrect data. A nonrepeatable read occurs when one transaction reads a row of data, another transaction modifies that row, and then the first transaction rereads the row and finds a different value. In this case, after a transaction reads data from the database, it has no guarantee that the data is still when it s used. A phantom read occurs when one transaction reads all rows from a table that satisfy a WHERE condition, then another transaction adds a new row that satisfies the WHERE condition, and finally the first transaction requeries the table and is able to see the new phantom row. In order to determine how a database connection treats data in light of these three transactional interaction categories, JDBC defines five transaction isolation levels, shown in Table 7-4. Table 7-4. JDBC Transaction Isolation Levels Isolation Level Description TRANSACTION_NONE Indicates that the driver does not support transactions and is therefore not a JDBC-compliant driver TRANSACTION_READ_UNCOMMITTED Allows transactions to see uncommitted changes to the data, meaning that dirty reads, nonrepeatable reads, and phantom reads are possible TRANSACTION_READ_COMMITTED Indicates that any changes made inside a transaction are not visible outside the transaction until the transaction is committed, which prevents dirty reads, but not nonrepeatable reads and phantom reads TRANSACTION_REPEATABLE_READ Disallows dirty reads and nonrepeatable reads, but permits phantom reads TRANSACTION_SERIALIZABLE Specifies that dirty reads, nonrepeatable reads, and phantom reads are not permitted, thus a serializable transaction is fully ACID-compliant As the transaction isolation level increases from the least restrictive (TRANSACTION_NONE) to the most restrictive (TRANSACTION_SERIALIZABLE), it increases the database overhead and hence degrades performance. You need to carefully evaluate your business requirements against these transaction isolation levels and choose the least restrictive level that meets those business requirements. Summary This chapter has provided a great deal of tuning information that can be applied generically across application server vendors. It began by reviewing the Java EE 5 specification and deriving the requirements for an application server to sufficiently implement this specification. From these
Note: If you are looking for cheap and reliable webhost to host and run your mysql application check mysql web server services.

204 CHAPTER 7 TUNING AN APPLICATION SERVER (Windows 2003 server web)

Friday, July 20th, 2007

204 CHAPTER 7 TUNING AN APPLICATION SERVER To further complicate things, each JDBC connection maintains its own prepared statement cache, so the memory requirement for the prepared statement cache is multiplied by the number of database connections. For example, if your prepared statement cache is sized to hold 100 prepared statements, and you have 50 database connections, then you are potentially putting 5,000 prepared statements in memory at one time. Therefore this value needs to be carefully adjusted, especially for database-intensive applications. Tune this value to the lowest possible value that minimizes the prepared statement discard rate. Configuring Advanced JDBC Options Tuning JDBC is not limited to container settings such as connection pools and prepared statement caches, but also includes deployment options that manage the concurrency models between database connections reading from and writing to the same data in a database. Concurrency management is implemented through the notion of a transaction: a transaction has a rich history that was initially applied to relational databases and characterized using the acronym ACID. An ACID transaction is defined as having the following characteristics: Atomicity: A transaction is said to be atomic, or treated as a single unit, when either all actions must complete or the entire transaction is aborted. A partially successful atomic transaction does not exist; it is either completely successful or a total failure. Consistency: A consistent transaction either creates a new and valid state in the database when it succeeds or returns all data to its original state upon failure, as if the transaction never occurred. Isolation: A transaction is isolated when it ensures that actions performed inside a transaction are not visible to other transactions until after the transaction is committed. Durability: A transaction is durable when all changes that it makes and successfully commits to a database are permanent, and therefore will survive system failures. JDBC has mimicked much of the ACID transaction functionality, but has also opened up transactional behavior to your control, so that, given your business requirements, you can optimize transactional performance. A full ACID transaction is expensive to manage, and in some business cases, you do not need your transactions to be fully ACID and would benefit from the database being a little lax in your transactional requirements. JDBC exposes this control by defining transaction isolation levels. The JDBC 4.0 specification defines transaction isolation levels as specifying what data is visible to statements within a transaction. They greatly impact the level of concurrent access by defining what interaction, if any, is possible between transactions against the same target data source. 1 And it places possible transaction interactions into three categories: Dirty reads Nonrepeatable reads Phantom reads 1. Sun Microsystems, Inc., JDBC 4.0 Specification: JSR 221 (December 2005), p. 54. Also available online at http://jcp.org/aboutJava/communityprocess/pr/jsr221/index.html.
We recommend you use shared web hosting services, because many users agree that it is cheap, reliable and customer-satisfying webhost.

CHAPTER 7 TUNING AN APPLICATION SERVER (Zeus web server) support

Friday, July 20th, 2007

CHAPTER 7 TUNING AN APPLICATION SERVER support only a single thread at a time, you can force the container to enforce this requirement by marking your servlet as implementing the javax.servlet.SingleThreadModel marker interface. This interface has been deprecated as of the Servlet API 2.4 and should no longer be used and for good reason it creates an additional wait point in your application. The reason to mention this tuning option is that if you ever see SingleThreadModel in your servlet code, then the code needs to be refactored to ensure that it is thread-safe and that the SingleThreadModel demarcation is removed. Non-thread-safe servlets require servlets to be pooled, which increases memory overhead, and they introduce another wait point that you need to tune, so do not use them. Tuning Prepared Statement Caches Prepared statements are interesting enhancements to Java EE applications: they parameterize JDBC calls to accomplish both SQL statement precompilation and reuse. The concept is to prepare the statement once with parameterized values and then reuse it on subsequent calls, rather than execute similar SQL statements repeatedly against a database. For example, the following statements can be converted to prepared statements: SELECT * FROM users WHERE user_id = 1; SELECT * FROM users WHERE user_id = 2; SELECT * FROM users WHERE user_id = 3; Instead, these statements can be rewritten as follows: SELECT * FROM users WHERE user_id = ?; From a Java programming perspective, instead of executing this statement from a java.sql.Statement, execute it from a java.sql.PreparedStatement. The following code: Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery( “SELECT * FROM users WHERE user_id=1″ ); then changes to the following: PreparedStatement ps = conn.prepareStatement( “SELECT * FROM users WHERE user_id=?” ); ps.setInt( 1, 1 ); ResultSet rs = ps.executeQuery(); The JDBC driver maintains these prepared statements in its own cache, and when it sees a call to prepareStatement(), it first checks to see if it has the precompiled statement before going to the database to compute a database explain plan for it (which defines how the database is going to execute the query). As always, the sizing of the cache is very important, because while a properly sized cache can dramatically improve performance, a poorly sized cache can dramatically hinder performance. Even a small cache imposes the overhead of checking the cache, making the trip to the database to prepare the statement, and then managing the cache (selecting a candidate to remove from the cache to make room for the new statement). If you see a high prepared statement discard rate on your prepared statement cache, then its size should be increased, but you need to be cognizant of the memory requirements for maintaining the cache.
If you are looking for affordable and reliable webhost to host and run your business application visit our ftp web hosting services.

202 CHAPTER 7 TUNING AN APPLICATION SERVER (Http web server)

Thursday, July 19th, 2007

202 CHAPTER 7 TUNING AN APPLICATION SERVER Tuning the JMS In applications with limited or no messaging, JMS tuning is unproductive, but the situation is different for applications that heavily rely on JMS. JMS is only a specification; the underlying implementation differs from vendor to vendor, and most application server vendors allow you to plug in your choice of JMS implementations. JMS operates in two modes: point-to-point messaging and publish/subscribe messaging. When using point-to-point messaging, one process puts a message on a JMS destination (a queue), and another process removes the message from the destination. When using publish/subscribe messaging, a message producer publishes a message to a JMS destination (a topic), and all subscribers to that destination receive the message. There are two primary facets of JMS tuning: Container tuning Message delivery tuning Some JMS containers impose limitations on the number of messages and/or bytes that can reside in a JMS destination at a given time. The limitations purpose is to minimize the impact of the JMS server on your application server heap if the JMS server consumes a significant amount of heap memory, then it impacts the effectiveness of garbage collection and, in the worst case, can lead to out-of-memory errors. If you are heavily using JMS, then you need to ensure that these size limits are properly managed. The JMS server needs to hold enough messages so as not to reject new incoming messages, but JMS consumers need to remove messages fast enough to mitigate memory issues. JMS defines levels of reliability for message delivery, and your choice of reliability will be a balance between business requirements and performance. Messages can be defined to be persistent or nonpersistent: a persistent message ensures that a message is delivered once and only once to a message consumer, whereas a nonpersistent message only requires that a message be delivered at most once to a message consumer. A persistent message is more reliable and can withstand a JMS provider failure, but it does so at a greater performance cost. The JMS 1.1 specification recommends, for the highest level of assurance that a message has been properly produced, reliably delivered, and accurately consumed, that a persistent message should be produced from within one transaction and consumed within another transaction from a nontemporary queue or a durable subscriber. The point is that if you want to guarantee that your messages are properly delivered to your consumers and receive an acknowledgment, it will cost you. Compare your business requirements to these options and configure your message delivery and transactional constraints to meet your business require ments with the least performance overhead. Understanding Servlet Pooling and the Impact of Non-Thread-safe Servlets By default, servlets run in a thread-safe fashion, meaning that multiple threads can access a single servlet at the same time. The main property of a thread-safe servlet is that, in the context of servicing a request, it does not rely on any stateful information maintained in the servlet itself. For example, you store a user s information in an HttpSession object rather than in a servlet member variable, because if two threads store their respective users information in the same servlet member variable, they are going to overwrite each other. If you require that your servlet
In case you need affordable webhost to host your website, our recommendation is ecommerce web host services.

Web hosting reseller - CHAPTER 7 TUNING AN APPLICATION SERVER my

Thursday, July 19th, 2007

CHAPTER 7 TUNING AN APPLICATION SERVER my students in my servlets and JSP class is looking at the intermediate source code that the translator generates. Listing 7-8 shows a readable sample of what this resultant servlet may look like. Listing 7-8. Sample Servlet Source Code Generated from a JSP File public void service( HttpServletRequest req, HttpServletResponse res ) { PrintWriter out = res.getWriter(); out.println( “” + “Hello, JSP!” ); } Although this code is a gross simplification of the true resultant file, you would not be surprised to look at these files yourself and see this simple out.println() call somewhere in the middle of the resultant servlet. Looking at these intermediate files is such a powerful tool that I routinely utilize this in teaching students how to write JSPs. Considering all of the nuances of the JSP specification can be a little overwhelming, but seeing the results of the various options makes it crystal clear. For example, the following code snippet: <% Integer n = new Integer( 10 ); %> <%=n%> is translated in the servlet to the following: Integer n = new Integer( 10 ); out.println( n.toString() ); And this code: is translated in the servlet to the following: out.println( mybean.getName() ); This example is a great learning exercise, but you may be wondering what it has to do with performance. Obviously, returning static content in an HTML file is much faster than generating a JSP file that writes the information back to the client, but the real issue is that when each JSP file is requested, it must pass through these translation and compilation phases before it can be loaded into system memory to create an instance in the heap. Translation and compilation are expensive operations, so many application servers provide the ability to precompile your JSP pages on or prior to deployment. For example, Tomcat provides access to the Jasper JSP Engine through an ant task that you can employ to precompile your JSP files. Precompiling will eliminate the translation and compilation phases when a user hits a JSP file for the first time. Although not precompiling JSP files can have a huge impact on the performance of your application, I opted to put it in the fine-tuning category for the simple reason that it only affects the first user that accesses the page. Once the JSP has been compiled and loaded into memory the first time, it is served from memory on subsequent invocations.
In case you need quality webspace to host and run your web applications, try our personal web hosting services.