JVM tunning: Should I remove the Metaspace setting...
# cfml-general
d
JVM tunning: Should I remove the Metaspace setting. It is currently set to 192MB, which I think is default. In my application.log I see this:
"Error","ajp-nio-127.0.0.1-8014-exec-111","07/15/22","13:35:38","2A6C741F4FCF2B85354682B4B3F82EB2","Metaspace The specific sequence of files included or processed is: E:\api\index.cfm"
in the last 5 hours it been logged about 50 times.
I think I'll just I'll double it and keep an eye on over the next week.
s
Which version of the JVM? Yes, generally, on recent versions of the JVM you should not set the Metaspace limits, you should let the JVM manage that, and 192MB is probably way too low. This came about because the CF install used to set PermGen space and when the JVM switched to Metaspace instead, the ACF team incorrectly just switched the PermGen limit option over to Metaspace 😞
Our production settings (we run JDK18 in production right now but these have been our settings for several previous JDK versions):
Copy code
-XX:-OmitStackTraceInFastThrow -XX:+UseG1GC -XX:MaxGCPauseMillis=100 -Xlog:gc,gc+metaspace,gc+cpu:file=/path/to/server-gc.log -Xmx512m
(obvs the
-Xmx
heap option should be whatever you need it to be for your server processes) So the only limit we set is max heap and we let the JVM manage everything else. The
OmitStackTraceInFastThrow
is to prevent the JVM optimizing away the stacktrace in repeated exceptions so you don't lose exception details (I can't understand why they made that the default!).
👍🏾 1
d
Thank you @seancorfield I like that recommendation about the stacktrace.
@seancorfield I'm on
java 11.0.1 2018-10-16 LTS
s
@Daniel Mejia I just checked and the GC config above is what we switched to when we went from JDK8 to JDK11. Not sure when we added the stacktrace flag but I think that also dates back to at least JDK11?
d
@seancorfield does the gc log file get big? is that path to an existing log file? I''ve never seen that in the cf logs.
and is it required for -XX:+UseG1GC ?
s
Sorry, I forget how little most CFers know about the JVM... The GC file will be created automatically (but the directories in that path will need to exist!) and it will automatically roll over (at about 20MB) and keep the last five archives -- based on what I see on our production servers.
The
UseG1CGC
option tells the JVM which garbage collector to use -- there are a lot of options! G1 is good for low-pause, high-throughput such as web apps.
The max GC pause option is a hint to tell GC how big a pause you're willing to take -- we've found 100ms to be a good compromise for occasional "big" GC work. It's a hint, not a fixed limit, so occasionally it'll be exceeded but mostly we don't get anywhere close to such large pauses (and for some systems you can set it to 500ms or more and still see good throughput). The GC log file tells you a lot about how effective your GC settings are... but you'll have to dig into the Oracle docs for JVM tuning if you really want to push things.
We've settled on these options because they're "good enough" under nearly all situations for our apps but all apps are different and traffic patterns affect GC tuning etc, etc.
d
Thank you.