Configuring JVM Settings in a WildFly / JBoss Domain

This tutorial will illustrate how to configure JVM Settings in a WildFly / JBoss EAP Domain

The JVM settings of WildFly / JBoss EAP Domain Domain server instances can be configured at different levels: At Host Controller level, at Server Group level and on individual Server level.

A default jvm configuration is defined on each Host Controller:

        <jvm name="default">
            <heap size="64m" max-size="256m"/>
            <jvm-options>
                <option value="-server"/>
                <option value="-XX:MetaspaceSize=96m"/>
                <option value="-XX:MaxMetaspaceSize=256m"/>
                <option value="--add-exports=java.base/sun.nio.ch=ALL-UNNAMED"/>
            </jvm-options>
        </jvm>

The attribute size controls the the initial heap size allocated by the JVM, while the max-size controls the the maximum heap size that can be allocated by the JVM.
You can control -XX JVM options (such as Garbage Collection Algorithms) through the option element of jvm-options.

The Host Controller JVM settings for the “default” jvm can be changed by setting any of its attributes

 /host=host1/jvm=default:write-attribute(name=max-heap-size,value=1024)

You can also create a new JVM definition for your Host Controller by using the add operation, which allows to specify the initial attribute of the JVM:

 /host=host1/jvm=large_jvm:add(heap-size=2048m, max-heap-size=2048m, max-permgen-size=512m, stack-size=1024k, jvm-options=["-XX:-UseParallelGC"])

Overriding the Host Controller JVM settings

The Host Controller JVM settings can be overridden if you have JVM settings defined at Server Group level as in this example:

<server-group name="main-server-group" profile="full">
            <jvm name="default">
                <heap size="1000m" max-size="1000m"/>
            </jvm>
            <socket-binding-group ref="full-sockets"/>
</server-group>

Here is, for example, how to define the Initial Heap size in the main-server-group:

 /server-group=main-server-group/jvm=default:write-attribute(name=heap-size,value=512)

Here is on the other hand how you can set the maximum heap size in the same Server Group:

 /server-group=main-server-group/jvm=default:write-attribute(name=max-heap-size,value=1512)

This is the result on your configuration of the above changes:

<server-group name="main-server-group" profile="full">
            <jvm name="default">
                <heap size="512" max-size="1512"/>
            </jvm>
            <socket-binding-group ref="full-sockets"/>
</server-group>

The Server Group configuration can in turn be overridden at Server level. As an example, we will see how to apply specific JVM settings for the Server “server-one”.

First of all, let’s check if the Server already has a custom jvm setting:

/host=host1/server-config=server-one:read-children-resources(child-type=jvm)
{
"outcome" => "success",
"result" => {}
}

As confirmed by its configuration, the Server server-one has no custom JVM settings:

<servers>
        <server name="server-one" group="main-server-group"/>
</servers>

Therefore you need to add the JVM settings, which allows to set the values for it:

/host=host1/server-config=server-one/jvm=default:add(heap-size=1024,max-heap-size=1024)

If the JVM attribute is already defined for a server, then you can simply use the write-attribute operation:

[/host=host1/server-config=server-one/jvm=default:write-attribute(name=heap-size,value=512)

What is the purpose of the JVM settings contained in domain.conf? These settings do not affect the individual Servers of the Domain but just the Host Controller JVM Process.