Chapter 4. JVM tuning Configuring optimal 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. 4.1. Setting a fixed heap size You must set an appropriate heap size to prevent out of memory errors. The -Xms option sets the initial heap size, and -Xmx sets the maximum heap size. It is recommended for production environments that you set the initial and maximum heap size options to the same size, so that the heap size is fixed and pre-allocated. For example, the following options set a 2048 MB heap size: It is recommended that you 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. To enable the G1 collector, use the following JVM option: 4.2.1. Garbage collection logging options Garbage collection logging is enabled by default for standalone JBoss EAP servers. 4.3. Enabling large pages Enabling 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. You must ensure that your operating system configuration allows for processes to use large pages. 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 Windows Server systems, the user that is running JBoss EAP must have the large pages privilege assigned: 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. For more information, see the Oracle documentation on Java support for large pages . 4.4. Setting 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. If the limits applied to JBoss EAP processes are too low, you will see a warning like the following when starting JBoss EAP: 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.5. Host controller and Process controller JVM tuning JBoss EAP managed domain hosts have separate JVMs for the host controller and process controller. 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.
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