简体   繁体   中英

JVM GC logging from AWS Lambda?

Can anyone suggest an applicable strategy for logging GC events from within AWS Lambda execution?

I am looking into something as close as possible to -XX:+PrintGC kind of logging, but since I can't really send any startup parameters to the lambda JVM process, it seems like the only way is by live JMX introspection? If that is the only way, any library or standardized approach applicable for AWS Lambda (tools that depend on running process, like VisualVM are unfortunately out of question)?

I'm not familiar with AWS Lambda, but if you are looking for JMX introspection you can find code example by link below.

https://github.com/aragozin/jvm-tools/blob/master/sjk-core/src/main/java/org/gridkit/jvmtool/MBeanGCMonitor.java

Unfortunately, JMX information isn't as rich as GC logs, but some information such as per generation memory dynamics are available.

It does not work with all available arguments, but you can set the JAVA_TOOL_OPTIONS environment variable in your AWS lambda to pass such flags. For example, I'll often pass "-verbose:class" to debug poor cold start performance.

Use jvisualvm in the jdk bin directory. It's an excellent tool

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM