Performance related issues (TPS, QPS, IOPS, and JVM parameters, etc.)

      As a developer, you must often encounter these two errors, PermGen Space, Out of Memory errors, so how do they cause them?

 

    (1) PermGen space [ commonly used when the web server pre-compiles JSP ]

    The full name of PermGen space is Permanent Generation space, which refers to the permanent storage area of ​​memory. OutOfMemoryError: PermGen space, on the surface, is the benefit of memory, and the solution must be to increase the memory. Talk about why the memory will come out: This part is used to store the information of Class and Meta. The Class is put into the PermGen space area when it is loaded. It is different from the Heap area where the Instance is stored, and the GC (Garbage Collection) will not be in the area. The PermGen space is cleaned up when the main program is running, so if your APP loads a lot of CLASS, it is very likely that a PermGen space error will occur. 

    Correction method: -Xms256m -Xmx256m -XX:MaxNewSize=256m -XX:MaxPermSize=256m , of course, the size is adjusted according to the actual situation. If it is in tomcat, manually set the MaxPermSize size. Modify TOMCAT_HOME/bin/catalina.sh and add the following line above echo "Using CATALINA_BASE: $CATALINA_BASE": JAVA_OPTS="-server -XX:PermSize=64M -XX:MaxPermSize=128m 

 

   ( 2) java.lang.OutOfMemoryError: Java heap space Heap size Setting the setting of the JVM heap refers to the setting of the memory space that the JVM can allocate and use during the running process of the java program. The JVM will automatically set the value of the Heap size when it is started. The initial space (ie -Xms) is 1/64 of the physical memory, and the maximum space (-Xmx) is 1/4 of the physical memory. It can be set by using options such as -Xmn -Xms -Xmx provided by the JVM. The size of Heap size is the sum of Young Generation and Tenured Generation. Hint: This exception will be thrown if 98% of the time in the JVM is used for GC and the available Heap size is less than 2%. Tip: The maximum Heap Size should not exceed 80% of the available physical memory. Generally, the -Xms and -Xmx options should be set to the same, and -Xmn is 1/4 of the -Xmx value.  
 Solution: Manually set Heap size Modify TOMCAT_HOME/bin/catalina.sh Add the following line above "echo "Using CATALINA_BASE: $CATALINA_BASE"": JAVA_OPTS="-server -Xms512m -Xmx512m -XX:MaxNewSize=256m" 

         Original address: http://blog.csdn.net/fengyie007/article/details/1780375

        There is a comment in the above URL that is also well written: Start the tool that comes with the JDK, the jconsole.exe memory monitoring tool under \jdk1.6.0_10\bin, click to enter as follows: Select the process with PID 4472 , Click to enter the following interface [the picture is omitted, when you click on a different memory block, you must wait a few seconds for the jconsole view to refresh, remember ! ! !

Select the memory page, and select the last option in the chart "Memory Pool "Perm Gen", the following details show:
The maximum value of this place is 65536Kb, which is 64M, so I found the reason, 64M will definitely It caused an overflow, but I configured several hundred megabytes of memory, but it didn't take effect. Note that this is the result I saw when I started tomcat in myclipse.
Next, I entered the "rem - ---- Execute The Requested Command -" This is followed by the following statement set JAVA_OPTS=%JAVA_OPTS% -Xms256m -Xmx1024m -XX:PermSize=256M -XX:MaxNewSize=256m -XX:MaxPermSize=512m, this place should pay attention to increase The location is after rem ----- Execute The Requested Command –, it is best to set JAVA_OPTS=%JAVA_OPTS% This should also be added. Many documents on this network do not explain this location clearly, or it is not this place. Is it possible in other places, I haven't tried it. I manually start tomcat, enter: startup in the cmd state, and then look at jconsole.exe, the memory of Perm Gen is the memory I configured 521M, it is effective.
But I am in After starting tomcat in myclipse and redeploying the program, the error remains the same. The original document "Linux and Windows Modifying the Memory Size of Java Virtual Machines" ( http://duanfei.iteye.com/blog/1189541 ) mentioned that
    if Tomcat is started through Myeclipse Revise
Myeclipse configuration options open options.. enter the tomcat keyword, then click on the JDK under Server, and the configuration area Optional Java VM arguments will appear.

Directly add -Xms128m -Xmx512m  
This place has a loophole, directly add "-Xms128m -Xmx512m ", it should be "-Xms256m -Xmx512m -XX:PermSize=256m -XX:MaxPermSize=512m", this is valid for myclipse . If there is no -XX:PermSize=256m -XX:MaxPermSize=512m, then the memory of PermGen is always 64M. After the modification, restart tomcat, redeploy, and the memory will no longer overflow.
On my machine: Optional Java VM arguments in Servers/Tomcat/Tomcat 6.x/JDK:
Find the reason, and the solution is naturally very simple.
Note that there is another parameter in this place Servers/Tomcat/Tomcat 6.x: Optional program arguments, this does not seem to have much effect, and I also have no effect after modifying it. I thought it would be OK to modify this place, which led me to take a detour. . 

 

 

Set the debug JVM memory information of eclipse integrated tomcat

         1) Open Run ==> Run(Debug) Configurations/Arguments in eclipse in turn, and add at the end of the VM arguments column: -Xms256m -Xmx1024m -XX:PermSize=256M -XX:MaxNewSize=256m -XX:MaxPermSize =512m As shown in the figure:



 

 

  ============================================================================

 The other two problems TPS, QPS, and IOPS of the disk, refer to the following two addresses

 (1)  http://jackyrong.iteye.com/blog/1747517

Theoretically, the average maximum IOPS of the disk can be calculated, that is, IOPS = 1000 ms/ (Tseek + Troatation), ignoring the data transfer time. Assuming that the average physical seek time of the disk is 3ms, and the disk speed is 7200, 10K, 15K rpm, the theoretical maximum IOPS of the disk are, respectively,  
IOPS = 1000 / (3 + 60000/7200/2) = 140  
IOPS = 1000 / (3 + 60000/10000/2) = 167  
IOPS = 1000 / (3 + 60000/15000/2) = 200 

1000 is 1 second = 1000 milliseconds, 3ms is the disk seek time, the average rotation delay of the disk at 7200 rpm is about 60*1000/7200/2 = 4.17ms, the data transfer time is much less than the two, and generally ignored.

 

In actual measurement, the IOPS value will be affected by many factors, including I/O load characteristics (read and write ratio, sequential and random, number of worker threads, queue depth, data record size), system configuration, operating system, disk drive, etc. .

  Wikipedia address: http://en.wikipedia.org/wiki/IOPS

 

 

 (2) http://blog.itpub.net/22664653/viewspace-767265/

Summary:
Questions is a record of all selects since mysqld was started, and the number of dml times includes the number of queries for the show command. This is somewhat inaccurate. For example, many databases have monitoring systems running, and a show query is performed on the database every 5 seconds to obtain the current database status, and these queries are recorded in the QPS and TPS statistics, resulting in certain "data" Pollution".
If there are many myisam tables in the database, the calculation is still more appropriate.
If there are many innodb tables in the database, it is more appropriate to use the com_* data source for calculation.

 

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326405221&siteId=291194637