Loading...
 

General GC recommendations

Catch 22


Time spent performing GC can depend on several factors, one of the primary ones is the total allocated heap size. For this reason when deciding on how much heap to allocate to the VM you would first ask, Does my application require high response times? or high throughput. For example high R/T would be for an interactive application used by customers. While a high throughput application would consist of backend processes not seen by users.

So

  • larger heap = longer but less frequent GC pauses
  • smaller heap = shorter but more frequent GC pauses

Configure for high R/T


start with smaller heap settings up to 6G in size.

Configure for high Throughput


start off with large heap 6G+

Which GC type?


Depending on your hardware and java version will affect which GC type can offer you the best option. For example on a host with one CPU core you will either use -XX:+UseSerialGC for the serial collector or if you require good response times and serial is too impacting then use -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode for CMS incremental.


Either Paralleloldgc or CMS for a server with multiple cores. More cores will improve the speed of the parallel executed STW phases reducing GC time.

If you have the most recent Java versions 7+ then the new G1 collector -XX:+UseG1GC.
This is designed to be a future replacement for CMS. Overall it has shown to be better and is similar in that is it targeted for high R/T based apps.

weak generational hypothesis


It is important in GC settings to correctly set your space for short lived objects, because most objects soon become unreachable & References from old objects to young objects only exist in small numbers we need to adjust these parameters right. Best to experiment with settings which can start diverse ranging from 25-50% of your total heap allocated to young gen space. Controlled with -XX:NewSize && -XX:MaxNewSize for dynamic Young Gen or use -Xmn for a fixed young generation.(unless your using G1GC)