Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it common practice to turn on GC logging in production Java server?

Tags:

I see in a few places [1] people start the GC logging in production servers (mission critical), e.g.

java -server -Xms1024m -Xmx1024m -XX:NewSize=256m \      -XX:MaxNewSize=256m \      -XX:+UseConcMarkSweepGC \      -XX:CMSInitiatingOccupancyFraction=70      -XX:+PrintGCDetails \      -XX:+PrintGCDateStamps \      -XX:+PrintTenuringDistribution \      -Xloggc:logs/gc.log \      -Djava.awt.headless=true      -Dcom.sun.management.jmxremote -classpath ... 

Is it recommend practices in production env these days?

Update: I have included a link [2] from Oracle also suggest to monitor GC on production servers.

Sources:

[1] https://serverfault.com/questions/121490/java-opts-xxprintgcdetails-affect-on-performance

[2] http://docs.oracle.com/cd/E24290_01/coh.371/e22838/deploy_checklist.htm#CHHFADDF

like image 750
Howard Avatar asked Mar 09 '13 06:03

Howard


People also ask

Does GC logging affect performance?

Other than some additional disk I/O activity for writing the log files, enabling garbage collection logging does not significantly affect server performance.

What is the use of GC logs?

Java Garbage Collector (GC) logs are used for memory management and object allocation and promotion. GC logs consist of critical information such as the duration of the GC process, the number of objects promoted, and more. It includes details of the entire GC process and the resources it uses.

What is the option to enable the GC trace in Java parameters?

To activate the detailed GC logging, we use the argument -XX:+PrintGCDetails.


1 Answers

Yes, this is a common practice. This is often highly recommended and I give examples and references below.

Why GC logging is good for production Java servers:

  1. Minimal Overhead - The GC logging has a minimal overhead to the overall system performance.

    • This is claimed e.g. by Charlie Hunt, ex-JVM Performance Architect and co-author of the Java Performance book.
    • all the world record SPEC Benchmarks running Java Enterprise software are running production servers with GC logging enabled. This confirms that the logging has low overhead and also that the logging path is highly tuned by the performace experts publishing the benchmark results.
  2. Long-term logging is absolutely crucial to the analysis of the Application Performance. The GC logging must be enabled all the time so that the Administrators are able to observe the GC behavior and tune the application accordingly.

like image 124
Aleš Avatar answered Jun 18 '23 09:06

Aleš