High CPU from StandardContext.backgroundProcess & WebappLoader.modified in ContainerBackgroundProcessor thread
Environment
- JBoss Enterprise Web Server (JWS)
- 3.x
- Tomcat 7.0.x
- Tomcat 8.0.x
- 5.x
- Tomcat 9.0.x
- 3.x
Issue
- We see high CPU from the following in the ContainerBackgroundProcessor thread on Tomcat:
"ContainerBackgroundProcessor[StandardEngine[Catalina]]" #72 daemon prio=5 os_prio=0 tid=0x00007f07438e2000 nid=0x4c5d runnable [0x00007f06f5a6a000]
java.lang.Thread.State: RUNNABLE
at java.io.UnixFileSystem.canonicalize0(Native Method)
at java.io.UnixFileSystem.canonicalize(UnixFileSystem.java:172)
at java.io.File.getCanonicalPath(File.java:618)
at org.apache.catalina.webresources.AbstractFileResourceSet.file(AbstractFileResourceSet.java:90)
at org.apache.catalina.webresources.DirResourceSet.getResource(DirResourceSet.java:101)
at org.apache.catalina.webresources.StandardRoot.getResourceInternal(StandardRoot.java:281)
at org.apache.catalina.webresources.Cache.getResource(Cache.java:62)
at org.apache.catalina.webresources.StandardRoot.getResource(StandardRoot.java:216)
at org.apache.catalina.webresources.StandardRoot.getClassLoaderResource(StandardRoot.java:225)
at org.apache.catalina.loader.WebappClassLoaderBase.modified(WebappClassLoaderBase.java:692)
at org.apache.catalina.loader.WebappLoader.modified(WebappLoader.java:343)
at org.apache.catalina.loader.WebappLoader.backgroundProcess(WebappLoader.java:287)
at org.apache.catalina.core.StandardContext.backgroundProcess(StandardContext.java:5422)
Resolution
- The
reloadableoption comes with large performance overhead so disable this for improvement
Root Cause
reloadableis set to true for a context. For this option, the Content from tomcat.apache.org is not included.documentation notes:
Set to true if you want Catalina to monitor classes in /WEB-INF/classes/ and /WEB-INF/lib for changes, and automatically reload the web application if a change is detected. This feature is very useful during application development, but it requires significant runtime overhead and is not recommended for use on deployed production applications. That's why the default setting for this attribute is false. You can use the Manager web application, however, to trigger reloads of deployed applications on demand.
Diagnostic Steps
- If a heap dump is captured, identify problem contexts with an OQL like below:
SELECT reloadable, path.value.toString() FROM org.apache.catalina.core.StandardContext
Product(s)
Category
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.