Home > Articles > Programming > Java

Java Test Environment Construction and Tuning

  • Print
  • + Share This
Learn test environment planning basics such as using an isolated network to ensure repeatability. Walk through an example of how to develop network capacity estimates for your Web site and test environment; discuss hardware and software tuning issues common to database servers, test clients, application servers, and other key web site components; and examine a strategy for progressively performance testing these components.
This chapter is from the book

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.

Figure 9.1 Figure 9.1 An example test environment

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 backups.

Figure 9.2 Figure 9.2 Shared network impact

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.1 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.2 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.

Table 9.1 Estimated Network Traffic Burden


Network Burden

Outbound HTML/static elements


Inbound HTTP requests


Application data transfer


HTTP session data transfer




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.


Many companies actively monitor their networks for network protocol analyzer activity. Some companies consider a network protocol analyzer a breech 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.

  • + Share This
  • 🔖 Save To Your Account