Thursday, April 30, 2015

How To Improve JBoss AS 7 / JBoss EAP 6.x Performance

Hi all, let's talk about performance over JBoss App Server...for example, JBoss EAP 6.3

I will give some clues about JBoss Performance...how to improve the container

- Datasources

Try to use prefill...

<datasource jta="true" jndi-name="java:/jdbc/<xpto>" enabled="true" use-ccm="false"> pool-name="<pool>"

<transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation> <!-- Serializable can be a good choice, depending reads of course -->
<pool>
<min-pool-size>8</min-pool-size>
<max-pool-size>32</max-pool-size>
<prefill>true</prefill>
</pool>
...
<!-- mysql for example try to use batch statements -->
<connection-property name="rewriteBatchedStatements">true</connection-property>
<connection-property name="maintainTimeStats">false</connection-property>

</datasource>


- EJB

<subsystem xmlns="urn:jboss:domain:ejb3:1.4">
    ...
<pools>
<bean-instance-pools>

<strict-max-pool name="slsb-strict-max-pool" max-pool-size="600"
instance-acquisition-timeout="1" instance-acquisition-timeout-unit="SECONDS"/>

<strict-max-pool name="mdb-strict-max-pool" max-pool-size="150"
instance-acquisition-timeout="1" instance-acquisition-timeout-unit="SECONDS"/>

</bean-instance-pools>
</pools>
   ...
<remote connector-ref="remoting-connector" thread-pool-name="default">
  <channel-creation-options>
  <option name="WORKER_READ_THREADS" value="2" type="xnio"/>
  <option name="WORKER_WRITE_THREADS" value="2" type="xnio"/>
  <option name="MAX_INBOUND_MESSAGES" value="150" type="remoting"/>
   <option name="MAX_OUTBOUND_MESSAGES" value="150" type="remoting"/>
   </channel-creation-options>
</remote>

  <thread-pools>
           <thread-pool name="default">
           <max-threads count="150"/>
           <keepalive-time time="60" unit="minutes"/>

      </thread-pool>
  </thread-pools>

  <in-vm-remote-interface-invocation pass-by-value="false"/>
</subsystem>


- Infinispan and Hibernate Cache (LIRS instead of LRU)

<subsystem xmlns="urn:jboss:domain:infinispan:1.5">
    . . .
   <cache-container name="hibernate" module="org.jboss.as.jpa.hibernate:4" default-cache="local-query">

   <transport lock-timeout="60000"/>
   <local-cache name="local-query">
      <transaction mode="NONE"/>
      <eviction strategy="LIRS" max-entries="150"/>
      <expiration max-idle="200000" lifespan="200000"/>
   </local-cache>

   <local-cache name="entity">
      <transaction mode="NON_XA"/>
      <eviction strategy="LIRS" max-entries="17030000"/>
      <expiration max-idle="1200000" lifespan="1200000"/>
   </local-cache>
      ...
 </cache-container>
      ...
</subsystem>


- Threads


<subsystem xmlns="urn:jboss:domain:threads:1.1">
     <unbounded-queue-thread-pool name="thread-http">
        <max-threads count="300"/>
        <keepalive-time time="60" unit="minutes"/>
     </unbounded-queue-thread-pool>

     <unbounded-queue-thread-pool name="thread-ajp">
         <max-threads count="300"/>
         <keepalive-time time="60" unit="minutes"/>
      </unbounded-queue-thread-pool>
</subsystem>


- Web

<subsystem xmlns="urn:jboss:domain:web:2.1" default-virtual-server="default-host" native="true" >

<connector name="http" protocol="HTTP/1.1" scheme="http" socket-
binding="http" enable-lookups="false" executor="thread-http" max-connections="400" />

<connector name="ajp" protocol="AJP/1.3" scheme="http" socket-binding="ajp" enable-lookups="false" executor="thread-ajp" max-connections="400" />

<virtual-server name="default-host" enable-welcome-root="true">
     <alias name="localhost"/>
     <alias name="example.com"/>
 </virtual-server>

</subsystem>


- Huge Pages and JVM Heap Size (just an example about 6GB)

/etc/sysctl.conf → vm.nr_hugepages = n (use /proc/meminfo → large page size). Ex: n = 10

/etc/sysctl.conf → kernel.shmmax = n ( maybe 3 times O. S Memory )
Try to avoid “error-no=22” when putting low values

/etc/sysctl.conf → vm.huge_tlb_shm_group = gid (gid groups). Ex: jboss groups


How to aply: sysctl -p

Example of values...
3072 large pages * 2048 KB page size – 3072 * 2048 = 6291456 (6GB / 2MB=3072)

Try to use the linux command
      "ulimit -a" or
      "ulimit -n"

So, check values for configurating and improve some properties to "unlimited" (see possibilities, of course).
Sample: how to see open files -> "lsof | grep jboss | wc -l"


So, use -XX:+UseLargePages for JVM Properties...as described before.

Another choose is using CMS collectors or default jvm values as:

<!-- JVM by Group Server -->
<jvm name="default">
<heap size="6GB" max-size="6GB"/>
<permgen size="256m" max-size="512m"/>
<jvm-options>
<option value="-XX:+DoEscapeAnalysis" />
<option value="-XX:+UseCompressedOops" />
<option value="-XX:+UseConcMarkSweepGC" />
<!-- option value="-XX:+HeapDumpOnOutOfMemoryError"/-->
</jvm-options>
</jvm>

See more about NUMA Architecture (non-uniform memory architecture - RHEL 6.x for example) to improve jboss process. See links about it.

NUMA
https://access.redhat.com/solutions/700683
https://access.redhat.com/solutions/48756

Huge Pages
https://access.redhat.com/solutions/317593
https://access.redhat.com/solutions/659103
https://access.redhat.com/solutions/69306 (HugePages Oracle)

JVM Options
https://access.redhat.com/solutions/629563
https://access.redhat.com/labsinfo/jvmconfig

Thanks a lot and see you on the next time...