Chapter 8. Configuring JVM settings


You can configure Java Virtual Machine (JVM) settings 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.

Note

Configure system properties in JAVA_OPTS if they need to be read by the JVM itself, or JBoss EAP modules (such as the logging manager), during the initial phase of startup of a standalone server, or a managed domain host controller.

8.1. Configuring JVM settings for a standalone server

You can define the Java Virtual Machine (JVM) settings for standalone JBoss EAP server instances at runtime by setting the JAVA_OPTS environment variable before starting the server. Alternatively, you can add the JVM settings to the standalone.conf or standalone.bat configuration file, and also by setting system properties. If system properties are set using multiple ways, the values in the JBoss EAP configuration file standalone*.xml override the other values.

Procedure

  • Setting the JAVA_OPTS environment variable:

    Linux

    $ export JAVA_OPTS="-Xmx1024M"

    Microsoft Windows

    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.
  • Besides setting the JAVA_OPTS environment variable, you can set system properties using one of the following alternative ways:

    • Execute the following command:

      $ EAP_HOME/bin/standalone.sh -Dmyproperty=value
    • Edit the JBoss EAP configuration file, standalone*.xml.
Warning

If system properties are set using multiple ways, the values in the JBoss EAP configuration file standalone*.xml override the other values, which may cause JBoss EAP startup issues. For example, if you have defined system settings in the JAVA_OPTS environment variable and in the JBoss EAP configuration file, the values in JBoss EAP configuration override the values in JAVA_OPTS.

8.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.

Note

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.

8.2.1. Defining JVM settings on a host controller

You can define Java Virtual Machine (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 procedure demonstrates creating a new JVM setting named production_jvm with some custom JVM settings and options. These settings are stored within the <jvm> tag in host.xml.

Prerequisites

  • JBoss EAP is running as a managed domain.

Procedure

  • Define JVM settings by using the management CLI.

    Syntax

    /host=<HOST_NAME>/jvm=<SETTING_NAME>:add(heap-size=<HEAP_SIZE>, max-heap-size=<MAX_HEAP_SIZE>, max-permgen-size=<MAX_PERMANENT_GENERATION_SIZED>, stack-size=<STACK_SIZE>, jvm-options=["<JVM_OPTIONS>"])

    Example

    /host=exampleHost1/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.

  • Define JVM settings by using the management console.

    1. Navigate to Runtime Hosts in the management console.
    2. Choose a host and click View.
    3. Select the JVMs tab to define the settings.

8.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. These settings for a server group are stored in domain.xml.

Prerequisites

Procedure

  • Applying JVM settings to a server group by using the management CLI.

    Create a server group name exampleGroupA that uses the production_jvm JVM settings.

    /server-group=exampleGroupA:add(profile=default,socket-binding-group=standard-sockets)
    /server-group=exampleGroupA/jvm=production_jvm:add

    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=exampleGroupA/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.

  • Applying JVM settings to a server group by using the management console.

    1. Navigate to Runtime Server Groups.
    2. Choose a server group and click View.
    3. Select the JVMs tab to apply the settings.

8.2.3. Applying JVM settings to an individual server in a server group

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. These settings for an individual server are stored in host.xml.

Prerequisites

Procedure

  • Applying JVM settings to an individual server by using the management CLI.

    Override the JVM definition in the Applying JVM settings to a server group procedure, and set the JVM settings for server-one to the default JVM definition:

    /host=exampleHost1/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=exampleHost1/server-config=server-one/jvm=default:write-attribute(name=heap-size,value="1024m")
  • Applying JVM settings to an individual server by using the management console.

    1. Navigate to Runtime Hosts.
    2. Choose the host, and click View on the server.
    3. Selecting the JVMs tab to apply settings.

8.3. Viewing the JVM resource status in the mananagement console

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.

Prerequisites

  • JBoss EAP is running.

Procedure

  • View the JVM status for a standalone JBoss EAP server:

    • Navigate to the Runtime tab, select the server, and select Status.
  • View JVM status for a JBoss EAP server in a managed domain:

    • Navigate to Runtime Hosts, select the host and server, and select Status.

The following heap usage information is displayed:

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.

For information about optimizing JVM performance, see JVM tuning in the Performance tuning for JBoss EAP guide.

Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.