WildFly JVM Settings: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
 
(13 intermediate revisions by the same user not shown)
Line 5: Line 5:
=Overview=
=Overview=


JVM settings can be declared in various server configuration files, as shown below. In domain mode, the settings declared in XML configuration files (domain.xml, host.xml) propagate to ''server node'' JVMs and they are subject to [[#Precedence_Rules|precedence rules]]; the process controller and host controller JVM settings are declared in [[#domain.conf|domain.conf]].
JVM settings can be declared in various server configuration files, as shown below.  
 
In domain mode, the server instance JVM settings can be declared both in [[domain.xml]] and [[host.xml]], and they are propagated by the domain controller and host controllers to the server instance JVMs. The effective values are subject to [[#Precedence_Rules|precedence rules]].
 
For the process controller and host controller JVM settings are declared in [[#domain.conf|domain.conf]].


=Configuration=
=Configuration=
Line 72: Line 76:
     ...
     ...
     <server-groups>
     <server-groups>
         <<b>server-group</b> name="..."><font color=green>
         <b><server-group name="..."></b><font color=green>
             <jvm java-home="..."  
             <jvm java-home="..."  
                     type="SUN|IBM"  
                     type="SUN|IBM"  
Line 91: Line 95:
                 <launch-command>...</launch-command>
                 <launch-command>...</launch-command>
             </jvm></font>
             </jvm></font>
         </server-group>
         <b></server-group></b>
     </server-groups>
     </server-groups>
     ...
     ...
Line 99: Line 103:


<tt>host.xml</tt> allows "named" <tt><jvm></tt> declarations.
<tt>host.xml</tt> allows "named" <tt><jvm></tt> declarations.
<pre>
 
<host ..>
<host ..>
    ...
  ...<font color=green>
    <jvms>
  <jvms>
        <jvm name="jvm-a" ...>
      <jvm name="jvm-a" ... />
        </jvm name="jvm-b" ...>
      <jvm name="jvm-b" ... />
        ...
      ...
    </jvms>
  </jvms></font>
    ...
</host>
  <server name="..." group="...">
</pre>
    <font color=green><jvm name="..."/></font>
  </server>
</host>
 
===The Common Configuration Syntax===
 
<jvm name="...">
    <heap size="1000m" max-size="2000m"/>
    <jvm-options>
        <option value="-server"/>
        <option value="-XX:MetaspaceSize=256m"/>
        <option value="-XX:MaxMetaspaceSize=512m"/>
        <option value="-agentlib:jdwp=transport=dt_socket,address=8787,server=y,suspend=n"/>
    </jvm-options>
</jvm>


===Precedence Rules===
===Precedence Rules===
The more specialized child elements will override parent configuration, allowing for the declaration of specific server configuration without requiring exclusion at the host or server group level. The parent configuration is inherited by other levels.


At least for EAP 7.0.5, it seems that ''both'' domain.xml and host.xml settings are applied to the server node:
At least for EAP 7.0.5, it seems that ''both'' domain.xml and host.xml settings are applied to the server node:

Latest revision as of 20:49, 7 July 2017

Internal

Overview

JVM settings can be declared in various server configuration files, as shown below.

In domain mode, the server instance JVM settings can be declared both in domain.xml and host.xml, and they are propagated by the domain controller and host controllers to the server instance JVMs. The effective values are subject to precedence rules.

For the process controller and host controller JVM settings are declared in domain.conf.

Configuration

Standalone Mode

Modify standalone.conf as follows:

    ...
    JAVA_OPTS="-Xms1000m -Xmx2000m -XX:MetaspaceSize=256m -XX:MaxMetaspaceSize=512m ..."
    ...

Even if standalone*.xml allows for a <jvm> element, it seems it is not honored when specified. More research is needed on this.

Standalone Mode GC Logging

GC logging is turned on by default in standalone.sh:

... 
PREPEND_JAVA_OPTS="$PREPEND_JAVA_OPTS -verbose:gc -Xloggc:\"$JBOSS_LOG_DIR/gc.log\" -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=3M -XX:-TraceClassUnloading"
...

For more details on generic Java GC logging see

Java Garbage Collection Logging

Domain Mode

In domain mode, the settings declared in XML configuration files domain.xml and host.xml propagate to server node JVMs and they are subject to precedence rules. Process controller and host controller JVM settings are declared in domain.conf.

domain.conf

Declare the JVM settings for both process controller and host controller:

...
if [ "x$JAVA_OPTS" = "x" ]; then
   JAVA_OPTS="-Xms64m -Xmx512m -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true"
...

By default, both JVM types share the same configuration, but it can be differentiated by using HOST_CONTROLLER_JAVA_OPTS and PROCESS_CONTROLLER_JAVA_OPTS environment variables, as in the following example:

if [ "x$JAVA_OPTS" = "x" ]; then
   JAVA_OPTS="-Djava.net.preferIPv4Stack=true"
   ...
fi

if [ "x$PROCESS_CONTROLLER_JAVA_OPTS" = "x" ]; then
    PROCESS_CONTROLLER_JAVA_OPTS="-Xms52m -Xmx252m -XX:MaxMetaspaceSize=122m $JAVA_OPTS"
fi

if [ "x$HOST_CONTROLLER_JAVA_OPTS" = "x" ]; then
    HOST_CONTROLLER_JAVA_OPTS="-Xms53m -Xmx253m -XX:MaxMetaspaceSize=123m $JAVA_OPTS"
fi

...

domain.xml

<domain ...>
    ...
    <server-groups>
        <server-group name="...">
            <jvm java-home="..." 
                    type="SUN|IBM" 
                    env-classpath-ignored="true"
                    debug-enabled="false"
                    debug-options="...">
                <heap size="" max-size=""/>
                <permgen>...</permgen>
                <stack>...</stack>
                <agent-lib>...</agent-lib>
                <agent-path>...</agent-path>
                <java-agent>...</java-agent>
                <jvm-options>
                    <option name="...">....</option>
                     ...
                </jvm-options>
                <environment-variables>...</environment-variables>
                <launch-command>...</launch-command>
            </jvm>
        </server-group>
    </server-groups>
    ...
</domain>

host.xml

host.xml allows "named" <jvm> declarations.

<host ..>
  ...
  <jvms>
     <jvm name="jvm-a" ... />
     <jvm name="jvm-b" ... />
     ...
  </jvms>

  <server name="..." group="...">
    <jvm name="..."/>
  </server> 

</host>

The Common Configuration Syntax

<jvm name="...">
    <heap size="1000m" max-size="2000m"/>
    <jvm-options>
        <option value="-server"/>
        <option value="-XX:MetaspaceSize=256m"/>
        <option value="-XX:MaxMetaspaceSize=512m"/>
        <option value="-agentlib:jdwp=transport=dt_socket,address=8787,server=y,suspend=n"/>
    </jvm-options>
</jvm>

Precedence Rules

The more specialized child elements will override parent configuration, allowing for the declaration of specific server configuration without requiring exclusion at the host or server group level. The parent configuration is inherited by other levels.

At least for EAP 7.0.5, it seems that both domain.xml and host.xml settings are applied to the server node:

... /opt/jdk/bin/java -D[Server:app02] -Xms255m -Xmx765m -server -XX:MetaspaceSize=96m -XX:MaxMetaspaceSize=256m -server -XX:MetaspaceSize=95m -XX:MaxMetaspaceSize=255m ...

which shows that it's best to only specify a configuration in just one location.

Domain Mode GC Logging

For more details on generic Java GC logging see

Java Garbage Collection Logging