Next, optimize the application server at http://www.cnblogs.com/bolobeach/p/3178751.html. We don't like it. The common application server is the background program, but it is not only the background program, but also other programs. Here I mainly talk about the background program optimization. It is also built on weblogic and oracle databases. If weblogic is not used, please visit the Internet. I personally think weblogic is an artifact.
No more nonsense. Direct Method
I. jvm Optimization
Any java program is based on jvm, but it is rarely used for jvm optimization during project execution. I remember the jvm tuning mentioned in the last 40 W concurrent processing solution, here we will explain in detail.
1.1 garbage collection and heap size
Garbage Collection (GC) refers to the process in which the JVM releases the memory occupied by objects no longer used in the Java Heap, while Java Heap) it refers to the space for Java application objects to survive. Therefore, when optimizing the previous article, you should create less write objects ]. The heap size determines the GC frequency and time. The larger the heap, the lower GC frequency and the slower speed. The smaller the heap, the higher the GC frequency and the faster the speed. Therefore, GC conflicts with heap size. To obtain the desired Heap size, use the-verbosegc parameter (Sun jdk:-Xloggc: <file>) to open the detailed GC output. Analyzes the GC frequency and time, and obtains the heap Size Based on the memory size required by the application's maximum load.
Generally, we recommend that you use 70-80% of available memory (memory occupied by the operating system and other applications) to avoid overhead caused by heap size adjustment, set the minimum value of the memory heap to the maximum value-Xms =-Xmx. To prevent memory overflow, we recommend that you set the heap size to at least 256 MB in the production environment (Platform must be at least 512 MB) and MB to MB in the actual environment ~ The performance is optimal at around 1 GB, and above 2 GB is not desirable. When you adjust the memory, you may need to adjust the maximum memory allowed by the core parameter process. For sun and hp JVMs, a permanent domain too small (4 MB by default) may also cause memory overflow. The parameter-XX: MaxPermSize = 128 M should be added. We recommend that you set the temporary domain-Xmn size to 1/4 ~ Of-Xmx ~ 1/3. The value of listen vorratio is 8.
For better performance, we recommend that you set WebLogic to the product mode in the startup file. At this time, sun and hp jvm JIT engines are-server. By default, enabling the JIT compilation mode is also helpful for performance. Adjusting the Chunk Size and Chunk Pool Size may also increase the system throughput. In addition, you need to disable the display GC:-XX: + DisableExplicitGC.
Of course, using jRockit on Intel Platform (using parameter-jrockit) will undoubtedly greatly improve WebLogic performance.
1.1.2 jRockit Optimization
JRockit supports four types of garbage collectors: generational replication collector, single-space concurrent collector, generational concurrency collector, and parallel collector. By default, JRockit uses the generational concurrent collector. To change the collector, use-Xgc: <gc-name>. The four collectors are classified into gencopy, singlecom, gencon, and parallel. For better response performance, you should use the concurrent garbage collector-Xgc: gencon. You can use-Xms and-Xmx to set the initial size and maximum value of the stack, set the care domain-Xns to 10% of-Xmx. To achieve better performance, the parallel garbage collector-Xgc: parallel should be used. Because the parallel garbage collector does not use nursery, you do not need to set-Xns.
If your thread is larger than 100 or on linux, you can try to use the thin thread mode-Xthinthread and disable Native IO:-Xallocationtype: global.
JRockit also provides a powerful graphical monitoring tool Jrockit Management Console. For details about JRockit, visit: http://edocs.bea.com/wljrockit/docs81/index.html.
1.2 Server Optimization
The core component of WebLogic Server is composed of the listening thread, socket multiplexing, And the execution queue of the executable thread. After the server receives a connection request from the listening thread, it gives control over the connection to the socket multiplexing waiting to receive the request. Then, the socket multiplexing reads the request that leaves the socket and places the request and related security information or transaction processing environment together in the appropriate execution Queue (generally the default execution Queue ). When a request appears in the execution queue, an idle execution thread will take the request from the queue and return a response. Then, wait for the next request. Therefore, to improve WebLogic performance, you must adjust the performance of core components.
1.2.1 use the local I/O Library whenever possible
WebLogic Server has two socket multiplexing sets: Java version and local database. It is more effective to use a small local database. Enable Native IO (default) should be activated as much as possible. At this time, UNIX uses CPUs + 1 thread by default, and double CPU under Window. If the system cannot load the local database, a java. lang. UnsatisfiedLinkException will be thrown. In this case, you can only use Java socket multiplexing. You can adjust the percentage of socket readers, Which is 33% by default. You can set this parameter in the Console Server Tuning Configuration column.
1.2.2 adjust the default number of execution threads
The ideal default number of execution threads is determined by many factors, such as machine CPU performance, bus architecture, I/O, operating system process scheduling, and JVM thread scheduling. By default, WebLogic has 25 threads in the production environment. As the number of CPUs increases, WebLogic can increase the number of threads almost linearly. The larger the number of threads, the more time it takes to switch between threads. The smaller the number of threads, the more insufficient the CPU. To obtain an ideal number of threads, it must be tested repeatedly. During the test, adjustments can be made based on 25 * CPUs. When there are few Idle threads and the CPU utilization is low, you can increase the number of threads (each five threads increases ). For PC Server and Window 2000, it is recommended that each CPU is smaller than 50 threads, and the CPU utilization is about 90%. Currently, WebLogic execution Threads do not have the function to reduce the number of Threads. Therefore, set the Threads Increase parameter to 0 and do not change the priority.
2.2.3 adjust connection Parameters
The WebLogic Server uses the Accept Backlog parameter to specify the size of the queue requested by the Server to the operating system. The default value is 50. When the system is overloaded, this value may be too small. Connection Refused is reported in the log, causing the valid Connection request to be rejected. In this case, the Accept Backlog 25% can be increased until the Connection rejection error disappears. For Portal applications, the default value is often insufficient. The Login Timeout and SSL Login Timeout parameters indicate the Timeout time for normal connections and SSL connections. If the client connection is interrupted by the server or the SSL capacity is large, you can increase the value. These parameters can be found in the Console Server Tuning Configration configuration bar.
3. jdbc Optimization
Jdbc optimization is very important in projects, especially in big data, the Optimization of the JDBC Connection Pool is subject to the setting of the number of WebLogic Server threads and the number of database processes, and the size of the cursor. We usually use a connection in a thread, so the number of connections is not the more the better. To avoid resource consumption on both sides, we recommend that you set the maximum value of the connection pool to be equal to or slightly smaller than the number of threads. In addition, to reduce the overhead of new connections, set the minimum and maximum values to the same value.
Increasing the Statement Cache Size is helpful for applications that use a large number of PreparedStatement objects. WebLogic can Cache these objects for each connection. The default value is 10. You can increase the Statement Cache Size as needed to ensure that the database cursor Size is sufficient. For example, if you set the number of connections to 25 and the Cache Size to 10, the database may need to open 25*10 = 250 cursors. Unfortunately, when you encounter an application error related to PreparedStatement Cache, you need to set the Cache Size to 0.
Although the JDBC Connection Pool provides many advanced parameters that are useful in the development mode, most of them do not need to be adjusted in the production environment. We recommend that you do not set a Test table, and Test Reserved Connections and Test Released Connections do not need to be checked. Of course, if your database is unstable, you may need to open the above parameters.
Finally, let's take Oracle as an example. Oracle provides the thin driver and oci driver. In terms of performance, the oci driver is better than the thin driver, especially for large data volume operations. However, in simple database operations, the performance does not differ much. With the continuous improvement of the thin driver, this weakness will be compensated. Thin drivers are more portable than oci drivers. Therefore, we recommend that you use the thin driver. And the latest drive because the WebLogic server/bin directory class package may not be the latest, please refer to the Oracle site: http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/htdocs/jdbc9201.html