Advertise with us

Our eBooks

JBoss Performance Tuning part 1

JBoss tuning tip 9:  Tune the Heap ratio

This is one of most important tuning factor: the heap ratio. The heap ratio specifies how the amount of the total heap will be partitioned between the young and the tenured space.  What happens if you have lots of long lived data (cached data, collections ) ? maybe you're in this situation:

jboss performance tuning 

The problem here is that the long lived data overflows the tenured generation. When a collection is needed the tenured generation is basically full of live data. Much of the young generation is also filled with long lived data. The result was that a minor collection could not be done successfully (there wasn't enough room in the tenured generation for the anticipated promotions out of the young generation) so a major collection was done.

The major collection worked fine, but the results again was that the tenured generation was full of long lived data and there was long lived data in the young generation. There was also free space in the young generation for more allocations, but the next collection was again destined to be a major collection.
This will eventually bring your application to crawl !!!!!

By decreasing the space in the young generation and putting that space into the tenured generation (a value of NewRatio larger than the default value was chosen), there was enough room in the tenured generation to hold all the long lived data and also space to support minor collections. This particular application used lots of short lived objects so after the fix mostly minor collections were done.

NewRatio is a flag that specifies the amount of the total heap that will be partitioned into the young generation. It's the tenured-generation-size / young-generation-size. For example, setting -XX:NewRatio=3 means that the ratio between the young and tenured generation is 1:3

If you want a more precise control over the young generation : NewSize is the initial size of the young generation, MaxNewSize will specify the maximum size of the young generation

What is the recommeded heap ratios ? Set the tenured generation to be approximately two times the size of the young generation.
This recommendation is only a starting point, you have to tune from there and to do that you have to gather and analyze the garbage collection statistics.

JBoss tuning tip 10:  Monitor the free memory with monitors and snapshots 

See this tips:

How to monitor jboss graphically ?

How to monitor JBoss with snapshots?

JBoss tuning tip 11: Tune the Operating System

Each operating system sets default tuning parameters differently. For Windows platforms, the default settings are usually sufficient. However, the UNIX and Linux operating systems usually need to be tuned appropriately

Linux tuning parameters:
Since in Linux everything is a file, check the file-max parameter

$ cat /proc/sys/fs/file-max

set fs.file-max=102642  into /etc/sysctl.conf

Raise ulimit with /etc/limits.conf (or ulimit -n for current session)

Increase default socket send/receive buffer

# default socket receive buffer
$ sysctl -w net.core.rmem_default=262144

# default socket send buffer
$ sysctl -w net.core.wmem_default=262144

# max socket receive buffer
$ sysctl -w net.core.rmem_max=262144

# max socket send buffer size
sysctl -w net.core.wmem_max=262144

Optimize MTU. The TCP maximum transfer unit is 1512 on the Internet. If you are sending larger packets it's a good idea to increase MTU size in order to reduce packet fragmentation (especially if you have a slow network)

$ vi /etc/sysconfig/network-scripts/ifcfg-eth0

– add "MTU=9000" (for gigabit ethernet)
– restart the interface (ifdown eth0;ifup eth0)


Applications using Java native memory (such as java.nio API) may tune application performance and memory use by adjusting the MALLOC_ARENA_MAX environment variable.
Java native memory is managed by the glibc library which uses multiple memory pools that malloc can allocate memory from. Especially for threaded programs, using multiple memory pools can speed up memory allocation (be reducing locking) and improve overall performance.
With some memory allocation patterns, this performance improvement can come at the cost of somewhat greater app memory consumption. This may especially be the case for programs that create and destroy many threads and allocate lots of memory in those threads.
If your application has MALLOC_ARENA_MAX=2 set but has plenty of memory to spare, you may be able to see small gains in response time by increasing this value.


Use Big Memory Pages
Default page size is 4KB (usually too small!)
Check page size with:

$ cat /proc/meminfo

If you see "HugePage_Total," "HugePages_Free" and "Hugepagesize", you can apply this optimization

Here's how to do it (2GB Heap Size Example)

$ echo 2147483647 > /proc/sys/kernel/shmmax
$ echo 1000 > /proc/sys/vm/nr_hugepages

In Sun's JVM, add this flag: XX:+UseLargePages

Solaris tuning parameters:

Check the following TCP parameters with your sysadmin:

/dev/tcp tcp_time_wait_interval
/dev/tcp tcp_conn_req_max_q
/dev/tcp tcp_conn_req_max_q0
/dev/tcp tcp_ip_abort_interval
/dev/tcp tcp_keepalive_interval
/dev/tcp tcp_rexmit_interval_initial
/dev/tcp tcp_rexmit_interval_max
/dev/tcp tcp_rexmit_interval_min
/dev/tcp tcp_smallest_anon_port
/dev/tcp tcp_xmit_hiwat
/dev/tcp tcp_recv_hiwat
/dev/ce instance
/dev/ce rx_intr_time 

Tip: Use the netstat -s -P tcp command to view all available TCP parameters.

Set TCP-related tuning parameters using the ndd command


$ ndd -set /dev/tcp tcp_conn_req_max_q 1638

Tune /etc/system filesystem

Each socket connection to JBoss consumes a file descriptor. To optimize socket performance, you may need to configure your operating system to have the appropriate number of file descriptors.

See Solaris documentation about this parameters:

set rlim_fd_cur
set rlim_fd_max
set tcp:tcp_conn_hash_size (Solaris 8 and 9)
set ip:ipcl_conn_hash_size (Solaris 10)
set shmsys:shminfo_shmmax Note: This should only be set for machines that have at least 4 GB RAM or higher.
set autoup
set tune_t_fsflushr
© 2021 All Rights Reserved.

Please publish modules in offcanvas position.