The highly structured nature of applications built using J2EE technologies lends itself well to design patterns for performance optimization. This article examines a number of such patterns and suggests optimal ways of using them to improve latency, throughput, and overall scalability of J2EE applications.
Application Performance Defined
The standard performance metrics for computer systems are latency and throughput. In the context of J2EE applications, latency is the time that elapses between the moment a client request is received by the server and the moment a response is sent back. Throughput is the number of client requests that are handled per second.
Both latency and throughput are important. To achieve high performance, you want to minimize the latency of your application while increasing throughput. In practical terms, subsecond latency is usually sufficient for Web systems. Acceptable throughput rates vary depending on the application; however, throughput of hundreds of e-commerce (e.g., shopping cart) transactions per second is considered quite good.
Both latency and throughput define the performance of a system under a particular load. However, J2EE systems operate under rapidly changing loads, at times coping with an influx of client requests an order of magnitude greater than normal. The system's ability to cope with such an increased load is called scalability.
Typically, system performance degrades with increased client load: latency increases and throughput falls. When a poorly designed system is confronted with an unexpectedly high load (see Figure 1), its latency grows nonlinearly and becomes unacceptably high while throughput falls sharply. An ideal system maintains a constant latency regardless of the load level, while its throughput scales linearly with the load. While ideal systems don't exist, a well-designed system should scale well, maintaining low latency and high throughput under a wide range of loads. This article examines techniques for building such applications.
Structure of J2EE Applications
J2EE applications are comprised of three tiers of components - client, server, and enterprise information system (EIS) resources. The client can be a static page or an applet running in a browser(HTML or WML), or a J2EE client application running inside a J2EE client container. On the server tier, servlets and JavaServer Pages (JSPs) that run inside a Web container generate the application Web UI. EJBs that run in an EJB container encapsulate application logic and data access. A typical J2EE application uses a relational database as its EIS-tier. Figure 2 shows the relationship between J2EE components.
This article presents techniques that affect the performance of Java and database-backed systems in general, optimizations that apply to individual J2EE component types, and a number of J2EE application patterns that improve performance.
J2EE Application Performance Basics
At their core, J2EE applications are Java programs that utilize a database. As such, J2EE applications are subject to all performance principles that apply to traditional Java and database programming. Good coding techniques and efficient use of the database are a prerequisite for writing high-performance J2EE applications.






