-XX:+UseG1GC (JDK 1.7u4) -
G1 GC give more predictable pauses and latency with large heaps.
Print GC statistics
In order to be informed of any latencies caused by gc, you need to turn on gc logging. This is the magic combination of switches that works well:
-Xloggc:/some/relative/or/absolute/path/gc.log
-XX:+PrintGCDetails
-XX:+PrintGCTimeStamps
-XX:+PrintGCDateStamps
-XX:+PrintTenuringDistribution
Other rich variant:
-verbose:gc
-XX:+PrintGCDetails
-XX:+PrintGCTimeStamps
-XX:+PrintGCDateStamps
-XX:+PrintTenuringDistribution
-XX:+PrintPromotionFailure
-XX:+PrintClassHistogramBeforeFullGC
-XX:+PrintClassHistogramAfterFullGC
-XX:+PrintGCApplicationConcurrentTime
-XX:+PrintGCApplicationStoppedTime
-Xloggc:memory/gc.log
-XX:+HeapDumpOnOutOfMemoryError
-XX:HeapDumpPath=memory/heap.dump
-XX:+UnlockDiagnosticVMOptions
-XX:+PrintAssembly
-XX:+CheckJNICalls
Good latency pattern
Here is the list of the recommended JVM settings for low latency & high throughput (JDK 1.6):
-server
-Xms2048m
-Xmx2048m
-XX:+UseConcMarkSweepGC
-XX:+UseParNewGC
-XX:+AggressiveOpts
-XX:+CMSParallelRemarkEnabled
-XX:+CMSScavengeBeforeRemark
-XX:+UseCMSInitiatingOccupancyOnly
-XX:CMSInitiatingOccupancyFraction=65
-XX:CMSWaitDuration=300000
-XX:GCTimeRatio=19
-XX:+DisableExplicitGC
-XX:NewSize=128m
-XX:MaxNewSize=128m
-XX:PermSize=64m
-XX:MaxPermSize=64m
-XX:SurvivorRatio=88
-XX:TargetSurvivorRatio=88
-XX:MaxTenuringThreshold=15
-XX:MaxGCMinorPauseMillis=1
-XX:MaxGCPauseMillis=5
-XX:+HeapDumpOnOutOfMemoryError
-XX:HeapDumpPath=./gc_heap_dump/
-XX:+PrintGCDateStamps
-XX:+PrintGCDetails
-XX:+PrintTenuringDistribution
-Xloggc:./gc_log.log
Aggressive memory and execution settings
-server
-XX:+AggressiveHeap
-XX:+UseCompressedOops
-XX:+CompactFields
-XX:+CMSClassUnloadingEnabled
-XX:+UseSharedSpaces
-XX:-UseLoopPredicate
Linux system tuning
Max number of opened files
/etc/security/limits.conf
your_username soft nofile 32768
your_username hard nofile 65536