The most obvious performance problem is that the response time of the Web page slows down. In the Java EE system, the following more basic symptoms are often embodied:
Use of Application server resources
Usage of the JVM heap
Usage of system resources
Use of database resources
Network activity
These phenomena indicate that the Java EE application relies on a lot of external resources and is running in a hierarchical execution mode environment:
Because Java virtual machines and application servers mask the features of operating systems and hardware, architects should be more aware of the entire operating environment when designing software systems.
When designing software systems, architecture engineers should prioritize performance and scalability, and then start looking for easy to solve problems, often due to the inefficient access to the database and the excessive invocation of remote objects and methods. Next, the architecture engineer can continue to look for the obvious reasons, such as the cumulative impact of the algorithm and unnecessary overhead.
Now on the market each Java application Server has a lot of configuration items. Here is a brief introduction to some of the most common performance optimization configuration projects.
Many application servers have operating system configuration items or non-standard features related to the Java EE specification, which can improve system performance. It should be time to understand these performance configurations.
Java Virtual machine heap and garbage collection settings
The performance tuning base for any Java application involves the heap size and garbage collection settings. (This is mainly about Sun Hotspor JVM).
The heap can be divided into three generations, young (new), old and lasting. The memory base configuration of the Hotspot JVM includes the maximum heap size, the initial heap size, and the size of the younger generation heap. Refer to the following guidelines when configuring the maximum heap Hours:
The maximum size should be less than the physical memory to avoid the virtual saved page scheduling.
Need to subtract memory used by other processes
Optimizing during load tests
Be careful not to set the maximum heap size too large. The larger the heap, the more objects are saved in memory. The more objects in memory, the longer the recycle process.
General strategies for configuring the initial heap size include:
Set the initial size to the maximum heap size
Sets the initial size to 1/4 to 1/2 of the maximum heap size
For the younger generation heap size, Sun recommended is set to the maximum heap size of 1/3.
You can also choose a different garbage collection algorithm. The first is incremental garbage collection. The algorithm is meant to reduce the pause time of a single object, which results in a decline in overall recovery performance. The algorithm groups the objects that are referenced by each other, and then attempts to recycle them by group. The smaller the portion of the attempt to recycle, the less time it takes to recycle.
The 1.4.1 version of the hotspot JVM adds two garbage collection algorithms: Parallel Algorithms and concurrency algorithms.
Parallel algorithms have been implemented in the younger generation heap. On multiprocessor machines, this recycling algorithm uses multithreading to improve performance. Although this algorithm pauses all application threads, the recovery time is very fast due to the use of multiple CPUs. In the younger generation, the algorithm significantly reduces the downtime caused by recycling.
The concurrency algorithm is implemented in the older generation heap. Maximize concurrency in your application. The recycle process is divided into 4 stages, overwriting the markup and cleanup operations of recyclable objects. The first two procedures suspend the application thread and the latter two phases can be executed concurrently with the application. The "Maximum concurrency" feature of concurrent garbage collection algorithms enables the JVM to take advantage of larger heaps and multiple CPUs. Attention should therefore be paid to the latency and throughput problems associated with garbage collection algorithms such as the default mark-compact (tag-compression) and Stop-the-world (pause all processing).