Chapter 9. Configuring JVM Settings
Configuration of Java Virtual Machine (JVM) settings is different for a standalone JBoss EAP server, or a JBoss EAP server in a managed domain.
For a standalone JBoss EAP server instance, the server startup processes pass JVM settings to the JBoss EAP server at startup. These can be declared from the command line before launching JBoss EAP, or using the System Properties page under Configuration in the management console.
In a managed domain, JVM settings are declared in the host.xml
and domain.xml
configuration files, and can be configured at host, server group, or server levels.
System properties must be configured in JAVA_OPTS
to be used by JBoss EAP modules (such as the logging manager) during startup.
9.1. Configuring JVM Settings for a Standalone Server
JVM settings for standalone JBoss EAP server instances can be declared at runtime by setting the JAVA_OPTS
environment variable before starting the server.
An example of setting the JAVA_OPTS
environment variable on Linux is shown below.
$ export JAVA_OPTS="-Xmx1024M"
The same setting can be used in a Microsoft Windows environment:
set JAVA_OPTS="Xmx1024M"
Alternatively, JVM settings can be added to the standalone.conf
file, or standalone.conf.bat
for Windows Server, in the EAP_HOME/bin
folder, which contains examples of options to pass to the JVM.
Setting the JAVA_OPTS
environment variable will override the default values from standalone.conf
, which may cause JBoss EAP startup issues.
9.2. Configuring JVM Settings for a Managed Domain
In a JBoss EAP managed domain, you can define JVM settings at multiple levels. You can define custom JVM settings on a particular host, and then apply those settings to server groups, or to individual server instances.
By default, server groups and individual servers will inherit the JVM settings from their parent, but you can choose to override JVM settings at each level.
The JVM settings in domain.conf
, or domain.conf.bat
for Windows Server, are applied to the Java process of the JBoss EAP host controller, and not the individual JBoss EAP server instances controlled by that host controller.
9.2.1. Defining JVM Settings on a Host Controller
You can define JVM settings on a host controller, and apply those settings to server groups or individual servers. JBoss EAP comes with a default
JVM setting, but the following management CLI command demonstrates creating a new JVM setting named production_jvm
with some custom JVM settings and options.
/host=HOST_NAME/jvm=production_jvm:add(heap-size=2048m, max-heap-size=2048m, max-permgen-size=512m, stack-size=1024k, jvm-options=["-XX:-UseParallelGC"])
See Managed Domain JVM Configuration Attributes for descriptions of all available options.
You can also create and edit JVM settings in the JBoss EAP management console by navigating to Runtime → Hosts, choosing a host and clicking View, and selecting the JVMs tab.
These settings are stored in the within the <jvm>
tag in host.xml
.
9.2.2. Applying JVM Settings to a Server Group
When creating a server group, you can specify a JVM configuration that all servers in the group will use. The following management CLI commands demonstrate creating a server group name groupA
that uses the production_jvm
JVM settings that were shown in the previous example.
/server-group=groupA:add(profile=default, socket-binding-group=standard-sockets) /server-group=groupA/jvm=production_jvm:add
All servers in the server group will inherit JVM settings from production_jvm
.
You can also override specific JVM settings at the server group level. For example, to set a different heap size, you can use the following command:
/server-group=groupA/jvm=production_jvm:write-attribute(name=heap-size,value="1024m")
After applying the above command, the server group groupA
will inherit the JVM settings from production_jvm
, except for the heap size which has an overridden value of 1024m
.
See Managed Domain JVM Configuration Attributes for descriptions of all available options.
You can also edit server group JVM settings in the JBoss EAP management console by navigating to Runtime → Server Groups, choosing a server group and clicking View, and selecting the JVMs tab.
These settings for a server group are stored in domain.xml
.
9.2.3. Applying JVM Settings to an Individual Server
By default, an individual JBoss EAP server instance will inherit the JVM settings of the server group it belongs to. However, you can choose to override the inherited settings with another complete JVM setting definition from the host controller, or choose to override specific JVM settings.
For example, the following command overrides the JVM definition of the server group in the previous example, and sets the JVM settings for server-one
to the default
JVM definition:
/host=HOST_NAME/server-config=server-one/jvm=default:add
Also, similar to server groups, you can override specific JVM settings at the server level. For example, to set a different heap size, you can use the following command:
/host=HOST_NAME/server-config=server-one/jvm=default:write-attribute(name=heap-size,value="1024m")
See Managed Domain JVM Configuration Attributes for descriptions of all available options.
You can also edit server JVM settings in the JBoss EAP management console by navigating to Runtime → Hosts, choosing the host, clicking View on the server, and selecting the JVMs tab.
These settings for an individual server are stored in host.xml
.
9.3. Displaying the JVM Status
You can view the status of JVM resources, such as heap and thread usage, for standalone or managed domain servers from the management console. While statistics are not displayed in real time, you can click Refresh to provide an up-to-date overview of JVM resources.
To display the JVM status for a standalone JBoss EAP server:
- Navigate to the Runtime tab, select the server, and select Status.
To display the JVM status for a JBoss EAP server in a managed domain:
- Navigate to Runtime → Hosts, select the host and server, and select Status.
This shows the following heap usage information:
- Max
- The maximum amount of memory that can be used for memory management.
- Used
- The amount of used memory.
- Committed
- The amount of memory that is committed for the Java Virtual Machine to use.
Other information, such as JVM uptime and thread usage, is also available.
9.4. Tuning the JVM
For tips on optimizing JVM performance, see the JVM Tuning section of the Performance Tuning Guide.