I. Overview
When the FineReport report project is deployed to other application servers, there are certain configuration requirements for the application server. Therefore, when the application server cannot meet the use of the report project, there will be a risk of downtime.
FineReport needs to modify the memory and other parameters after deployment to ensure the stable operation of the server.
II. Modify heap memory
Please refer to the table below:
Parameter introduction | Server type | Reference documents |
---|---|---|
-Xmx parameter: maximum heap memory -Xms parameter: initial memory size Note 1: There should be no space between Xmx/Xms and the number Note 2: It is recommended to configure Xms=Xmx to prevent memory expansion failure | Tomcat server | Tomcat server memory modification |
WebLogic server | WebLogic server memory modification | |
WebSphere server | WebSphere server memory modification | |
JBoss server | JBoss server memory modification | |
Resin server | Resin server memory modification |
The heap memory configuration is recommended as follow:
Phsical machine | JVM | Recommend |
---|---|---|
32G memory、Report exclusive | 16G | -Xms16g -Xmx16g |
24G | -Xms24g -Xmx24g | |
16G memory、Report exclusive | 8G | -Xms8g -Xmx8g |
III. Set single thread to use stack space
It is recommended that the stack space used by a single thread does not exceed 512KB, that is, the value of -Xss does not exceed 512. This section shows the steps of setting -Xss in Tomcat environment.
Windows system:
Enter the %Tomcat%/bin directory, find and edit the configuration file catalina.bat, add another parameter after the existing configuration parameters set JAVA_OPTS= -Xms512M -Xmx1024M:
-Xss512K
As shown below:
After modification, restart the project. Check thecatalina.log file under %Tomcat%/logs, indicating that the configuration takes effect, as shown in the following figure:
Linux system:
Enter the %Tomcat%/bin directory, find and edit the configuration file catalina.sh, add another parameter to the existing configuration parameter JAVA_OPTS="$JAVA_OPTS -Xms2048M -Xmx8196M" statement:
-Xss512K
After modification, restart the project. Enter ps -ef|grep tomcat (modify the tomcat in the statement according to the actual situation) to view the process and check whether the parameter configuration is successful. If the parameter related information appears in the process information as shown below, it means the configuration is successful:
IV. Set the size ratio of the old generation to the young generation in the heap
The recommended size ratio of the old generation to the new generation in the heap is 2 (-XX:NewRatio=2, the default value of JVM); the normal effective size of NewRatio requires the user to not limit the size of the new generation.
In the position of setting -Xmx and -Xms parameters, just add the value of NewRatio. This section shows the steps of setting NewRatio in Tomcat environment.
Windows system:
Enter the %Tomcat%/bin directory, find and edit the configuration file catalina.bat, add another parameter after the existing configuration parameter set JAVA_OPTS= -Xms512M -Xmx1024M -Xss512K:
-XX:NewRatio=2
As shown below:
After modification, restart the project. Check the catalina.log file under %Tomcat%/logs, indicating that the configuration takes effect, as shown in the following figure:
Linux system:
Enter the %Tomcat%/bin directory, find and edit the configuration file catalina.sh, add another parameter to the existing configuration parameter JAVA_OPTS="$JAVA_OPTS -Xms2048M -Xmx8196M -Xss512K" statement:
-XX:NewRatio=2
After modification, restart the project. Enter ps -ef|grep tomcat (modify the tomcat in the statement according to the actual situation) to view the process and check whether the parameter configuration is successful. If the parameter related information appears in the process information as shown below, it means the configuration is successful:
V. Modify the MaxDirectMemorySize parameter
The off-heap memory is set by the parameter -XX:MaxDirectMemorySize, and the recommended parameter value is 2GB.
1. Direct deployment to modify parameters
If you install FineReport directly from the installation package, you can directly modify it in the designer.vmoptions file in the %FR_HOME%/bin directory. Both Windows and Linux/Unix systems modify this file (here is M as the unit), as shown in the figure below:
Increase the parameters as shown in the figure below:
-XX:MaxDirectMemorySize=2g
Restart the project after the configuration is complete.
2. Deploy to modify parameters in Tomcat
Windows system:
Configuration method: Enter the %Tomcat%/bin directory, find and edit the configuration file catalina.bat, and add the configuration:
set JAVA_OPTS=%JAVA_OPTS% -XX:MaxDirectMemorySize=2g
Represents MaxDirectMemorySize = 2GB, as shown in the figure below:
After modification, restart the project. Check the catalina.log file under %Tomcat%/logs, indicating that the configuration takes effect, as shown in the following figure:
Linux system:
Linux/Unix modify catalina.sh file and add configuration:
JAVA_OPTS="$JAVA_OPTS -XX:MaxDirectMemorySize=2g"
Restart the project after the configuration is complete. Enter ps -ef|grep tomcat (modify the tomcat in the statement according to the actual situation) to view the process and check whether the parameter configuration is successful. If the parameter related information appears in the process information as shown below, it means the configuration is successful:
3. Deploy to modify parameters in Weblogic
Modify the startWebLogic file under the Weblogic installation directory%Weblogic%/domains/user project name/ , and add a configuration.
Windows system:
Windows adds configuration in the startWebLogic.bat file:
set MEM_ARGS=-XX:MaxDirectMemorySize=2g #means MaxDirectMemorySize = 2GB
Restart the project after the configuration is complete.
Linux system:
Linux New configuration in the startWebLogic.sh file:
MEM_ARGS="-XX:MaxDirectMemorySize=2g" #means MaxDirectMemorySize = 2GB
As shown below:
Restart the project after the configuration is complete.
4. Deploy to modify parameters in Websphere
1) Method 1: Console editing (recommended)
Visit the Websphere console and enter the JAVA virtual machine configuration interface.Add JVM parameters in the input box:
-MaxDirectMemorySize=2096
As shown in the figure below:
2) Method 2: Modify the configuration file
Modify the configuration file server.xml in the Websphere installation directory and add JVM parameters in it:
MaxDirectMemorySize="2096"
As shown in the figure below:
Restart the project after the configuration is complete.
VI. Garbage collector
It is recommended to use the default Parallel Scavenge collector (parallel collector).
1. View the garbage collector currently in use
Note: If you use the statements in this section and the query result contains -XX:+UseParallelGC, then the content in Section VI-2 of this article will be ignored.
1)View under Windows
win+R enter cmd, the command is as follows:
java -XX:+PrintCommandLineFlags -version
As shown below:
2) View under Linux system
Enter the following command:
java -XX:+PrintCommandLineFlags -version
As shown below:
2. Set up the garbage collector
When the project is deployed on Tomcat, you can refer to the method in this section to set the garbage collector to Parallel Scavenge (parallel collector).
Windows System:
Enter the %Tomcat%/bin directory, find and edit the configuration file catalina.bat, and configure:
set JAVA_OPTS= -XX:+UseParallelGC
As shown below:
Linux System:
Enter the %Tomcat%/bin directory, find and edit the configuration file catalina.sh, configure:
JAVA_OPTS="$JAVA_OPTS -XX:+UseParallelGC"
After modification, restart the project. Refer to section VI-1 to view the garbage collector currently in use.
VII. Precautions
It is recommended that the remaining space of the disk where the project is located should not be less than 5G.
It is recommended that the total memory of the physical machine minus the memory used by the container where the system is located should not be less than 10GB.