Chapter 4. JVM tuning Configuring optimal Java virtual machine (JVM) options for your applications and JBoss EAP environment is one of the most fundamental ways to tune performance. This chapter covers configuring some general JVM options. Note Many of the JVM options listed in this chapter can be easily generated using the JVM Options Configuration Tool on the Red Hat Customer Portal. Additional resources Refer to the JBoss EAP Configuration Guide for instructions on how to apply JVM options to a standalone server or servers in a managed domain . 4.1. Setting up a fixed heap size To pre-allocate and fix the heap size on the production environments, you must set the initial and maximum heap size options to the same size. Procedure Set an appropriate heap size to prevent out of memory errors. Use the -Xms option to set the initial heap size and the -Xmx to set the maximum heap size. For example, the following options set a 2048 MB heap size: Test your applications under load in a development environment to determine the maximum memory usage. Your production heap size should be at least 25% higher than the tested maximum to allow room for overhead. 4.2. Configuring the Garbage Collector Although the parallel garbage collector, also known as the throughput garbage collector, is the default garbage collector in Java 8 for server-class machines , Red Hat recommends using the G1 garbage collector, which is expected to be the default from Java 9 onward. The G1 garbage collector generally performs better than the CMS and parallel garbage collectors in most scenarios. Procedure To enable the G1 collector, use the following JVM option: Garbage Collection Logging Options Garbage collection logging is enabled by default for standalone JBoss EAP servers. To enable garbage collection logging for a JBoss EAP managed domain, see enabling garbage collection . 4.3. Activating large pages Activating large pages for JBoss EAP JVMs results in pages that are locked in memory and cannot be swapped to disk like regular memory. Especially for memory-intensive applications, the advantage of using large pages is that the heap cannot be paged or swapped to disk, and is thus always readily available. One disadvantage of using large pages is that other processes running on the system might not have quick access to memory, which might result in excessive paging for these processes. As with any other performance configuration change, it is recommended that you test the impact of the change in a testing environment. Prerequisites Your operating system configuration is set to use large pages. Procedure If your operating system is not configured to use large pages for JBoss EAP processes, select one of the following options: For Red Hat Enterprise Linux systems, you must explicitly configure HugeTLB pages to guarantee that JBoss EAP processes will have access to large pages. For information on configuring Red Hat Enterprise Linux memory options, see the Memory chapter in the Red Hat Enterprise Linux Performance Tuning Guide . For Windows Server systems running JBoss EAP, you must assign the large pages privilege: Select Control Panel Administrative Tools Local Security Policy . Select Local Policies User Rights Assignment . Double-click Lock pages in memory . Add the Windows Server users and user groups that you want to use large pages. Restart the machine. Enable or disable large page support: To explicitly enable large page support for JBoss EAP JVMs, use the following JVM option: To explicitly disable large page support for JBoss EAP JVMs, use the following JVM option: When starting JBoss EAP, ensure that there are no warnings related to reserving memory. On Red Hat Enterprise Linux, an error might look like: On Windows Server, an error might look like: If you do see warnings, verify that your operating system configuration and JVM options are configured correctly. Additional resources For more information, see the Oracle documentation on Java support for large pages . 4.4. Activating aggressive optimizations Using the aggressive optimizations (AggressiveOpts) JVM option can provide performance improvements for your environment. This option provides Java performance optimization features that are expected to become default in future Java releases. Procedure To enable AggressiveOpts, use the following JVM option: 4.5. Setting soft and hard ulimits For Red Hat Enterprise Linux and Solaris platforms, you must configure appropriate ulimit values for JBoss EAP JVM processes. The "soft" ulimit can be temporarily exceeded, while the "hard" ulimit is the strict ceiling for the usage of a resource. Appropriate ulimit values vary depending on your environment and applications. Important If you are using IBM JDK, it is important to note that IBM JDK uses the soft limit for the maximum number of open files used by a JVM process. On Red Hat Enterprise Linux, the default soft limit ( 1024 ) is considered too low for JBoss EAP processes using IBM JDK. If the limits applied to JBoss EAP processes are too low, you will see a warning like the following when starting JBoss EAP: Procedure To see your current ulimit values, use the following commands: For soft ulimit values: For hard ulimit values: To set the ulimit for the maximum number of open files, use the following commands with the number you want to apply: To set the soft ulimit for the maximum number of open files: To set the hard ulimit for the maximum number of open files: Note To guarantee that a ulimit setting is effective, it is recommended on production systems to set the soft and hard limits to the same value. Additional resources For more information on setting ulimit values using a configuration file, see How to set ulimit values on the Customer Portal. 4.6. Host and process controller JVM tuning JBoss EAP managed domain hosts have separate JVMs for the host controller and process controller. See the JBoss EAP Configuration Guide for more information on the roles of host controllers and process controllers . You can tune the host controller and process controller JVM settings, but even for large managed domain environments, the default JVM configuration for the host controller and process controller should suffice. The default configurations for host controller and process controller JVMs have been tested with a managed domain size of up to 20 JBoss EAP hosts each running 10 JBoss EAP servers, for a total domain size of 200 JBoss EAP servers. If you experience issues with larger managed domains, you might need to monitor the host controller or process controller JVMs in your environment to determine appropriate values for JVM options such as heap size.

Commands:
-Xms2048M -Xmx2048M
-XX:+UseG1GC
-XX:+UseLargePages
-XX:-UseLargePages
OpenJDK 64-Bit Server VM warning: Failed to reserve shared memory. (error = 1)
Java HotSpot(TM) 64-Bit Server VM warning: JVM cannot use large page memory because it does not have enough privilege to lock pages in memory.
-XX:+AggressiveOpts
WARN [org.jboss.as.warn.fd-limit] (main) WFLYSRV0071: The operating system has limited the number of open files to 1024 for this process; a value of at least 4096 is recommended.
ulimit -Sa
ulimit -Ha
ulimit -Sn 4096
ulimit -Hn 4096