YOUR FEEDBACK
John Portnov wrote: This code does not work for me. I created a new website and a C# console applic...
AJAXWorld RIA Conference
$300 Savings Expire August 22
Register Today and SAVE!

SYS-CON.TV
TOP THREE LINKS YOU MUST CLICK ON


Performance Analysis for Java Web Sites
Performance Analysis for Java Web Sites

A good stress test uncovers any problem areas before deploying the web site to production. The time and expense of performance tests pays off in the gains realized in customer satisfaction and overall site reliability. So far, we've discussed building good performance tests for your web site. Now let's cover building a realistic environment in which to run these tests.

In short, you cannot go cheap in building your test environment. Poor infrastructure impacts performance and stress tests more than any other type of tests you'll run against your web site. Don't expect to meet your web site performance goals if you build the test environment with cheap cable, underpowered client machines, and low-bandwidth networks. To get the most out of your performance test efforts, the test environment must mimic the production environment as closely as possible, given the ever-present constraints of time and expense. Obviously, if the web site contains hundreds of servers, you cannot recreate a huge server farm for a performance and stress test. In these cases, scale down the test to a few machines, keeping the scale proportional to the production system. Figure 9.1 shows a typical small test cluster with peripheral systems.

Proportion remains important in "scale environments" in other ways as well. Again, if the 20 machines in the production cluster use 200 database connections, assume that the small cluster of two machines needs 20. The same goes for network bandwidth, test clients, and other resources you might need for the test. Also, when using a smaller environment, keep in mind the behavior of the system at two servers might be drastically different than with twenty. The web site team must test scalability in a small-scale environment.

Of course, the reduced costs of small-scale environments lead to reduced coverage of all the situations your large-scale web site faces in production. If you test with a small-scale environment, you may encounter undiscovered problems when you move to production. In fact, you may encounter problems you can only recreate on the production web site. The best test environment remains a full-scale reproduction of the production web site, whenever possible.

The Network
The network plays an enormous role in performance and stress testing, yet it rarely receives the attention it requires. The network often becomes a hidden source of problems and limitations during the test. Only after days or weeks of fruitless testing and problem resolution of higher-level components does the network come under scrutiny. Consider the network before testing begins. Estimate the amount of data the network must carry and plan sufficient network capacity for testing.

Network Isolation
As always, we want the test network as close as possible to the production setup. However, even if the production environment shares its network with other systems, build an isolated network for the stress and performance testing. Some companies balk at the expense and time that building an isolated network requires. However, without an isolated network, you cannot control the traffic volumes on the network during testing. We're often amazed at some of the traffic moving across an internal network, even during normal business hours. A few of the things we've seen in the field include

  • Heavy network traffic from employees connecting to a company-sponsored gaming server
  • Network "storms" created by a faulty network card somewhere on the network
  • Massive system backups moving across the network for hours at a time.

    In short, if you don't control the network, you don't control its traffic, either. Figure 9.2 shows some of the daily network traffic fluctuation factors. Some test teams try to work around this problem by running their tests at night or early in the morning. Sometimes this works, but often they discover their company uses the network 24 hours a day. As mentioned earlier, the networks might be in use at night for large data transfers and back-ups.

    If you must use a non-isolated network, try to set up a network protocol analyzer (more on how these work below) to monitor network traffic volumes. Before you do this, check with your corporate network team. Many companies restrict or forbid the use of network protocol analyzers on their networks. And, yes, they can find out if you install one anyway. The best solution remains building an isolated network.

    Remember, you need repeatability to perform an effective performance and stress test. Some test teams, however, cannot get the same results twice from the same performance test, even if they don't make any adjustments to the system under test. In such an environment, you cannot effectively tune the system. If you make a change, and see better performance, you cannot know if you've found a legitimate improvement or if the environment actually factors in the solution. Testing on an open network introduces more environment variability than you can ever hope to control.

    Network isolation is probably one of the most overlooked issues in performance testing, and yet it is one of the most important. If you can't know from one run to the next whether a change made improved things or not, your test dissolves into an exercise in dart-throwing as you struggle to understand your web site bottlenecks and optimal tuning.

    Network Capacity
    The network carries all the data for the test (and subsequently for the production environment). You need to do some network capacity planning prior to building the network, and certainly before beginning any tests. The network needs enough capacity to carry the data generated by the test. This begs the question: What data does the test generate, exactly? Here's a list of some common data packages the network handles during a performance test:

  • User/server communications
    - User HTTP requests
    - Server HTML responses
    - Embedded HTML page elements, such as gifs, jpegs, and JavaScript
    - Embedded frame elements (usually resulting in additional page requests)

  • Mid-tier (server-to-server)communications
    - HTTP session data sharing within a cluster
    - Application database transfers
    - Traffic to services servers (for example, a stock quote server)
    - Traffic to mail/messaging services
    - LDAP requests/responses
    - DNS requests/responses

  • Back-end (server-to-host)communications
    - Host databases transfers
    - Host application communications

    Usually the largest network impact comes from a few major sources:

  • HTML responses
  • Embedded elements such as gifs and jpegs
  • HTTP session data sharing within a cluster
  • Application database transfers

    However, as we've discussed before, every web site and web application differ. A good understanding of your particular web application, the kinds of pages it returns, and its interactions with other systems helps you put together a reasonable network traffic estimate.

    E-Commerce Network Capacity Planning Example
    e-Commerce web sites require lots of network bandwidth. As we discussed in Chapter 5, the pages returned by these sites usually contain lots of embedded pictures in the form of gifs and jpegs. Users browse the pages of the e-Commerce web site and perhaps search for groups of items ("Show me a selection of coffee pots," for example). Because these pages return items the customer probably hasn't seen before, the user's browser does not contain cached copies of the images. To build a network estimate, figure out the average and maximum page size returned to the users. Decide how frequently the maximum page size might go out to the users, and whether it merits special calculation as a worse case scenario. Again, this exercise results in estimates. Use the performance test to validate these estimates.

    Let's make the following assumptions about our e-Commerce site:

    • Average page size: 45KB
    • Maximum page size: 70KB
    Let's also assume you want to use a 100Mbps Ethernet network to support the web site. If the web site team hopes to move 100 pages per second through the site at peak (remember, we always plan for peak loading), the network receives sustained traffic of 4.5Mbps.

    45,000 bytes per page * 100 pages per second = 4.5MBps

    Note that 4.5MB approaches the upper bound of sustained traffic we consider acceptable for a 100Mbps Ethernet web site. Under ideal conditions, a 100Mbps network could potentially handle 12.5MB of sustained traffic:

    100Mbps / 8 bits per byte = 12.5MBps

    However, Ethernet networks lose efficiency because of traffic collisions and retransmissions. Academics tell us to expect an Ethernet to support 66% of its potential capacity, or about 8.3MBps of sustained traffic. For planning purposes, we prefer to use a more conservative estimate of 5MBps of sustained traffic. This allows the network to absorb unexpected traffic spikes. Web sites operating through a switched network are the exception to this rule. A switched network acts as a point-to-point network, which makes it more efficient. When dealing with switched networks, we raise the planning estimate to 8MBps.

    The 4.5MBps we estimated above tells us the peak outbound traffic on the web site. How much inbound traffic does the web site carry? Inbound traffic consists of HTTP requests, which we usually measure in terms of a few bytes. For example, if the average HTTP request requires 100 bytes, the network load generated at peak is 100 bytes/request * 100 requests/second = 10KB/second.

    This is less than 1% of the outbound HTML content traffic. Keep in mind that TCP/IP generates lots of overhead packets to support "guaranteed delivery" (a hallmark of the TCP/IP protocol). So, as a rule of thumb, we estimate inbound traffic at about 20% of outbound traffic. In this case, we'll use a planning estimate of

    4.5MBps * 20% = 900KBps

    Now, let's consider the transfer of data between the application servers and the application database on the network. Let's assume each user request requires the transfer of 10KB of data from the database. At peak, this gives us the following traffic:

    10,000 bytes per request * 100 requests per second = 1MBps

    If the web site uses HTTP session persistence, we need to account for this traffic as well. If each request generates 1KB of HTTP session traffic, we estimate the following HTTP session burden:

    1,000 bytes per request * 100 requests per second = 100KBps

    Lots of installations grossly underestimate the size of the HTTP session data they maintain for each user. Check the HTTP session database, and check the size of the data stored for your users to properly size the average HTTP session. See Chapter 2 for more details on HTTP session management.

    Other factors also influence the amount of HTTP session data on your network. HTTP session caching combined with affinity routing reduces the data read from a persistent HTTP session store. On the other hand, if your application server vendor supports a distributed HTTP session scheme, this sometimes generates more network traffic, depending on the implementation.

    The network burden estimates so far add up to the following, as shown in Table 9.1.

    At 6.5MBps of sustained traffic, this web site exceeds our planning limit of 5MBps for the 100Mbps Ethernet. The web site needs a more sophisticated network plan. We might consider a switched 100Mbps network rated at 8MBps, but this doesn't give the web site a lot of room for growth or for unexpected load peaks. A gigabit network might be a better fit for this web site.

    Network Components
    Networks consist of more than cable. Any number of switches, routers, load balancers, and other equipment make up the test environment network. The brands and types used largely depend on what's available for the test, as well as company standards. Frequently the test team reuses network equipment from other test projects or receives the equipment as a loan from a production group. Often, the equipment becomes a part of the test network without anyone really understanding how it works or how to configure it properly. The end result is a piece of equipment that may impact web site performance in ways difficult to detect without specialized monitoring equipment and skills.

    Keep in mind the following questions when dealing with network components:

  • Is the component rated for this network? We regularly find customers trying to use network equipment rated for a 100Mbps network on a gigabit network. Also, your diagnostic equipment, such as network protocol analyzers, may not work with ultra-high-speed networks.
  • How was the equipment used previously? Borrowed equipment often contains filters, limits, and other settings still in place from a previous assignment. For example, if you borrow a router previously used in a production web site, its current settings may intentionally limit HTTP connections to a defined maximum. While this protects against denial of service attacks in production, it limits the load you're able to generate against the web site during the test. Review the settings on all equipment to avoid unintentional limitations on performance.
  • Does the component support all the features the test environment requires? Routers, load balancers, and other components may or may not have features required by the web site. Know your requirements for key features such as affinity routing and SSL support, and understand how well the equipment supports your desired configuration.

    Network Protocol Analyzers and Network Monitoring
    A network protocol analyzer monitors traffic flows across a network and allows you to find out exactly how much traffic passes over the network during a test. If permitted, we highly recommend you use a network protocol analyzer to validate the network load during testing. Don't be surprised if your test generates a very different network load than you originally estimated. Often your estimates fail to consider all the factors at play during execution. Also, you may find the page sizes you used for your estimates incorrect.

    Network protocol analyzers vary greatly in sophistication and expense. The most expensive network protocol analyzers cost tens of thousands of dollars and work with high-speed networks. These high-end network protocol analyzers usually come with tools for analyzing the network traffic at various levels in the protocol stack. For test teams on a more limited budget, many free or inexpensive network protocol analyzers exist, and they usually run on a machine already connected to the network. They provide limited functionality and don't always work with high-speed networks. However, for providing a gauge of network activity on many classes of networks, these tools work just fine. Just be sure whatever tool you pick works with the network it will monitor. This requires checking the tool's tolerance for network type and network speed. Chapter 12 discusses these tools in more detail, and Appendix C contains a list of some vendors of these products.

    Warning: Many companies actively monitor their networks for network protocol analyzer activity. Some companies consider a network protocol analyzer a breach in their security and do not allow them. We've visited companies where using a network protocol analyzer on a company network results in instant job termination. Please take this warning seriously; obtain permission before inserting a network protocol analyzer into a network.

    The Servers
    The network connects all the components of your web site. Let's next go up a level and consider the server components you need in the test environment.

    Application Server Machines
    In terms of configuring the web application servers, strive to make the test configuration as close to the deployment configuration as possible. If you're deploying to a farm of four-way Sun machines with 8GB of RAM, you should use the same equipment during your testing, if at all possible.

    Even though the Java web application server might port to different platforms, web applications do not perform and scale the same on a one-way NT box as on a four-way Sun box. If you must choose between fewer servers for your test or smaller servers, pick fewer servers. When you use fewer servers, scale the other components of the test (databases, HTTP servers, and so on) proportionally as well.

    If you deploy the web application on multiple machines in a cluster, then test on multiple machines in a cluster as well. Get a representative number: If you plan to deploy on more than four machines, test on more than two. If your target environment contains eight application server machines or more, then four application servers in your test environment should suffice, as long as you scale the rest of the test web site proportionally to match.

    We often encounter test teams trying to test and tune all the software used in their web site (application servers, databases, HTTP servers, etc.) on a single machine. However, this technique doesn't work if the production web site actually uses multiple machines. For example, many production web sites separate their HTTP servers from their application servers. Often the production team places the HTTP servers in a DMZ with firewalls in front and behind, as shown in Figure 9.3. It is impossible to successfully performance test for this configuration with a single server machine. If the web site uses SSL, for example, the HTTP server needs so much CPU for encryption/decryption that it chokes the performance of the application server.

    Database Servers
    Most production web sites use mid-tier database servers to hold application data or data specific to the web site (such as an HTTP session database). Often the web applications access these databases on every user request. Despite their central role in the operation of the web site, the mid-tier databases sometimes receive little or no tuning before the site enters production deployment. Often the test team lacks the database administrator (DBA) skills required to tune the database properly. Thus the team ignores the database unless they stumble across a specific problem in production. The problems we see frequently with databases usually fall into one of two broad categories: Poor software configuration or poor hardware configuration.

    Poor Database Software Configuration: Indexing
    By far the biggest database tuning problem we encounter is poor table indexing. Usually the problem starts this way: The test team receives a database backup from the production database staff. They dutifully load the database definition and the data itself, but never bother to build indexes for the tables they've just loaded. In fact, they may not even know what an index is, much less how to build one. Chapter 6 discusses how to put together the performance test team, including DBA skills needed to tune environments using databases.

    The index allows the database software to find elements in a table without scanning the table repeatedly. This saves tremendous amounts of resource, particularly CPU. Also worth noting, the DBA may build new indexes and remove old ones as usage patterns change over time. New indexes apply even when web applications use existing databases. Often these databases contain indexes tailored for existing applications, but they might require new ones to better support the web application. By monitoring database reports, the DBA determines the web application's usage patterns and makes appropriate adjustments. The DBA may also review the SQL used in the web application to find out where indexes might be most beneficial.

    Poor Database Software Configuration:
    Internal Resources

    Web applications receive many simultaneous requests. In turn, they make a proportionally large number of simultaneous requests to the database servers supporting them. These database servers need enough resources to support large volumes of simultaneous requests. These resources include things such as buffer pools, cursors, and sockets to support high-bandwidth operation.

    Regrettably, we often see high-concurrency web sites struggling to pull data from databases tuned for small, fat client applications. New applications and usage patterns require a fresh look at the tuning parameters for the database. Do not assume the database is tuned properly because the DBA made a few tweaks some years ago for the usage patterns of a fat client application.

    Poor Database Software Configuration: Caching
    Particularly for sites with enormous application databases, the database cache becomes very important for optimal site performance. The cache holds the results of the most common queries and makes an impact on sites with large catalogs of items but a few frequently accessed "best sellers." These items return from the cache quickly without an expensive retrieval from the hard disk.

    Caching helps some web sites, but a few cannot take advantage of this feature. For example, if every query submitted by the web site is unique (if, say, every query contained the user's account number), the cache may not return a hit even though the query may return items retrieved many times before. The web site team might want to work with the DBA to build queries better able to use the caching mechanisms available.

    Poor Database Hardware Configuration: I/O Management
    Eventually, all databases interact with the hard disks to read or write data. Database tuning often focuses on the CPU required by the database server without focusing on how to manage the storage required by the same database. We sometimes see very large multiple-processor database machines spending most of their time waiting to access one tiny hard disk. Adding CPU does not solve disk I/O problems.

    If the database server spends most of its time waiting to read or write from the disk, tune the I/O resources. If the database supports it, try adding a multiplatter disk array to the database server. By using multiple disks, the database spreads out the read and write operations for better simultaneous access. The database reads and writes spread out across multiple points rather than queuing up on a single disk. Figure 9.4 shows an example using multiple disk platters.

    Likewise, the hard disks themselves often contain tunable features. Some disks allow the system administrator to specify buffering to the disk, which may also improve performance. Some databases write more efficiently to disk than even the native file system itself. For example, IBM's DB2 database product provides mechanisms for "raw" I/O management (DB2 bypasses the file system to write directly to the disk) and for multidisk data writing.

    Finally, when spreading the data to multiple hard disks, don't forget about the database logs. Databases keep detailed logs for rollback and recovery purposes. Every action taken by the database must be logged, and this requires a write to the hard disk. "Striping" these logs across multiple hard disks, if supported by the database, often improves disk I/O wait times.

    SIDEBAR
    About The Book
    Performance Analysis for Java Web Sites by Joines, Willenborg, and Hygh

    ISBN 0201844540
    $44.99 464 pp.
    Publication date:
    September 10, 2002
    Publisher: Addison- Wesley Professional

    Stacy Joines, Ruth Willenborg, and Ken Hygh

    About Ruth Willenborg
    Ruth Willenborg is a senior technical staff member in IBM's WebSphere Technology Institute working on virtualization. Prior to this assignment, Ruth was manager of the WebSphere performance team responsible for WebSphere Application Server performance analysis, performance benchmarking, and performance tool development. Ruth has over 20 years of experience in software development at IBM. She is co-author of Performance Analysis for Java Web Sites (Addison-Wesley, 2002).

    About Stacy Joines


    About Ken Hygh


  • YOUR FEEDBACK
    Jan Naude wrote: Relating to Doug Smith's question: Doug, I think you misunderstand MVC. The components are: Model (data retrieved/manipulated by business rules) View (responsible for rendering/displaying relevant information to user) Controller - business logic that operates on/manipulates model to produce data to be displayed by view. The idea with MVC is not to mix business logic (i.e. Servlets/Struts actions) and presentation logic (jsp/html) in the same artifacts (components), because then you end up not being able to replace/change one without having to replace/change the other. JSF focuses more on easily developing the View part, while Struts concentrates more on Model and Controller and their integration.
    Jose Arco wrote: Hi, Really interesting article. I have a related question. We have a web acces application based completly on Struts. Now we want to add a new funcionality based on JSF, the question is if we could have integration problems between both tools. Thanks in advanced
    bill wrote: it would be nice to redo this comparison TODAY in 2007 and see what comes out. Struts2 has really added a ton to their side and JSF components have matured. I would like to see a modern comparison- as there does not seem to be one.
    wildcat wrote: Hi, Yes JSF is the way to go. The thing which I like the most about JSF is the finer control given by the component based architechture which is the key for RAD tools..like .NET. Java is up there facing a string competition form .NET but hey JAVA will WIN.
    Doug Smith wrote: Friends, this is going to sound like a really dumb question, but I am asking in all sincerity. While I understand the arguments to separate view (screen) from model (database & rules) & control (keyboard), I'm not sure I understand why I need Struts or JSF to do this. I can put code a View as a JSP, interact with the Model using Javabeans, and exercise Control using HTML or JSP directives. What exactly are the benefits using either Struts or JSF? The cost is obvious - another set of things to learn and configure. (Asked by a solo practitioner who doesn't work with graphic designers).
    David Thirakul wrote: Very interesting article, thank you. We are currently working extensively with Struts for the presentation layer and are watching the progress of JSF with much interest because it seems to be the way to go in the long term. There is no doubt that JSF will take over as McClanahan stated himself when he was talking about migrating to JSF. (see http://www.theserverside.com/news/thread.tss?thread_id=29068). There's no new development on Struts as opposed to JSF which by the way is the answer to MS webforms. So to answer Tom's comment, yes there is overlaping and if you start a new project from scratch and want to compare struts and jsf, roland's article is very insightful. What I would like to point out also is that JSF seem to lack the ease of use and functionnality of webforms, that's why all the new development goes into JSF, there's a lot of catching up to do...
    Roland Barcia wrote: Thanks for the feedback. Craig has a vested interest in both frameworks. There are features in Struts that compliment JSF like Tiles and the Validation framework. But just because they have some areas where they can work together does not mean I cannot compare them both. In this article, I focus on the Core of the frameworks and how they differ. I see very little benefit with the current Struts implementation to mix the Struts controller with the JSF components.
    Tom Roche wrote: To speak of "JSF vs Struts" displays a lack of understanding of the different specializations of the two frameworks. JSF specializes in view, Struts in model and control. The two can be used together via the Struts-Faces Integration Library. As Craig McClanahan's inaugural blog post http://blogs.sun.com/roller/page/craigmcc/20040927#struts_or_jsf_struts_and points out: > For new development, here's the best strategy for determining what > to do: > * Evaluate the two technologies individually, to see if they satisfy > your requirements. > * If one or the other technology is sufficient, go ahead and use it > (it's easier to learn and use one technology rather than two where > possible); keeping in mind, however, the caveats about Struts HTML > tags mentioned above. > * If your requirements include unique features supported only by > Struts (such as Til...
    WEBSPHERE LATEST STORIES . . .
    IBM announced that Vantage Deluxe World Travel has increased sales and improved business operations since turning to IBM to run its Web site and online booking system. Since switching to IBM WebSphere Commerce software, Vantage Travel has reduced order-taking time by 80 percent and inc...
    Red Hat CTO Brian Stevens, Citrix CTO Simon Crosby, Egenera CTO Pete Manca, Allen Stewart, Group Manager, Windows Virtualization at Microsoft, and Brian Duckering, Sr. Director of Products and Alliances at Symantec were the top industry executives who joined Jeremy Geelan in the 4th Fl...
    Mike Neil is general manager for virtualization strategy in the Windows Server Division at Microsoft. Mike is focused on the delivery of the Windows virtualization technology, including Windows Server 2008 Hyper-V, Microsoft Hyper-V Server and Virtual PC 2007. Mike also directs the tec...
    The AJAX for IBM WebSphere Platform Early Program is an optionally installable product extension for IBM WebSphere Application Server Version 6.1 and WebSphere Application Server Community Edition that offers targeted, incremental new features that can make Web applications running on ...
    Two of the biggest launches in Rich Internet Application history took place in 2007/2008 when Adobe launched AIR 1.0 in February '08 and Microsoft launched Silverlight (September '07). At the 6th International AJAXWorld RIA Conference & Expo in October SYS-CON Events is delighted to be...
    Unify announced the expansion of its Composer for Lotus Notes solution through a partnership with CASAHL Technology. Partnering with CASAHL extends the Composer solution to include an assessment of the Lotus Notes infrastructure in order to inventory, categorize and analyze the types o...
    SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS
    SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
    Click to Add our RSS Feeds to the Service of Your Choice:
    Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
    myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
    Publish Your Article! Please send it to editorial(at)sys-con.com!

    Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021

    SYS-CON FEATURED WHITEPAPERS

    ADS BY GOOGLE
    BREAKING WEBSPHERE NEWS
    Today at the TDWI World Conference, IBM (NYSE: IBM) introduced new versions of two software product...