Performance test with Tomcat 9 shows increased cpu/disk usage because of repeated opening/closing of jars in WEB-INF/lib

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

Performance test with Tomcat 9 shows increased cpu/disk usage because of repeated opening/closing of jars in WEB-INF/lib

Rhuberg,Anthony
Background:
In the last few months we migrated our web application from Tomcat 7.0.55 to Tomcat 9.0.19 (26). That transition was relatively straightforward until we reviewed the results of our performance tests. Those tests showed an increase in CPU usage and disk I/O on our Windows 2012 server. When we switch back to Tomcat 7, the metrics for CPU/disk usage were significantly lower (similar to previous tests).

As we investigated the cause of the increase in cpu/disk usage we found the tomcat process was repeatedly opening and closing the jars of our web application. The process profile showed all the jars in WEB-INF/lib being closed and reopened within seconds while the application was processing requests (and to some extent when quite). Now we are trying to determine why.

We have a general understanding that the WebappClassLoaderBase.java implementation changed in Tomcat 8.5. The Tomcat 7 implementation provided for the configuration of  jarOpenInterval (which we used the default = 90s). The latest implementation appears to track the jar modification times with a hash map called jarModificationTimes, but we are unable to find a similar time-to-live configuration or what triggers the lifecycle listener to close the jars (what calls WebappClassLoaderBase.modified() or destroy()) - assuming we understand this lifecycle behavior.

The server is configured mostly with default settings. The Context reloadable property is NOT set. We have tried increasing the cache time of the Resources cacheTtl property as the default of 5s seemed close to the time the jars were reloaded. We have not been successful.

Question:
What is the cause of the repeated reloading of our web application jars? What can trigger the class loader to close all the file handles related to the jars in the web application WEB-INF/lib directory - and then open them again within a few seconds?



CONFIDENTIALITY NOTICE This message and any included attachments are from Cerner Corporation and are intended only for the addressee. The information contained in this message is confidential and may constitute inside or non-public information under international, federal, or state securities laws. Unauthorized forwarding, printing, copying, distribution, or use of such information is strictly prohibited and may be unlawful. If you are not the addressee, please promptly delete this message and notify the sender of the delivery error by e-mail or you may call Cerner's corporate offices in Kansas City, Missouri, U.S.A at (+1) (816)221-1024.

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: Performance test with Tomcat 9 shows increased cpu/disk usage because of repeated opening/closing of jars in WEB-INF/lib

Rhuberg,Anthony
Just noticed another thread on this topic: RE: Tomcat discards and reloads the jar files from the webapps folder.

Setting the Engine attribute backgroundProcessorDelay to 90s does reduce the open/close cycle of the jars.

The other thread also mentioned a potential configuration to keep the jars open longer by default. This could be helpful - not sure we need to close them at all.

Alternatively, would there be any gain to 'explode' the jars into class files on the filesystem?

-----Original Message-----
From: Rhuberg,Anthony <[hidden email]>
Sent: Wednesday, October 09, 2019 2:17 PM
To: [hidden email]
Subject: Performance test with Tomcat 9 shows increased cpu/disk usage because of repeated opening/closing of jars in WEB-INF/lib

Background:
In the last few months we migrated our web application from Tomcat 7.0.55 to Tomcat 9.0.19 (26). That transition was relatively straightforward until we reviewed the results of our performance tests. Those tests showed an increase in CPU usage and disk I/O on our Windows 2012 server. When we switch back to Tomcat 7, the metrics for CPU/disk usage were significantly lower (similar to previous tests).

As we investigated the cause of the increase in cpu/disk usage we found the tomcat process was repeatedly opening and closing the jars of our web application. The process profile showed all the jars in WEB-INF/lib being closed and reopened within seconds while the application was processing requests (and to some extent when quite). Now we are trying to determine why.

We have a general understanding that the WebappClassLoaderBase.java implementation changed in Tomcat 8.5. The Tomcat 7 implementation provided for the configuration of  jarOpenInterval (which we used the default = 90s). The latest implementation appears to track the jar modification times with a hash map called jarModificationTimes, but we are unable to find a similar time-to-live configuration or what triggers the lifecycle listener to close the jars (what calls WebappClassLoaderBase.modified() or destroy()) - assuming we understand this lifecycle behavior.

The server is configured mostly with default settings. The Context reloadable property is NOT set. We have tried increasing the cache time of the Resources cacheTtl property as the default of 5s seemed close to the time the jars were reloaded. We have not been successful.

Question:
What is the cause of the repeated reloading of our web application jars? What can trigger the class loader to close all the file handles related to the jars in the web application WEB-INF/lib directory - and then open them again within a few seconds?



CONFIDENTIALITY NOTICE This message and any included attachments are from Cerner Corporation and are intended only for the addressee. The information contained in this message is confidential and may constitute inside or non-public information under international, federal, or state securities laws. Unauthorized forwarding, printing, copying, distribution, or use of such information is strictly prohibited and may be unlawful. If you are not the addressee, please promptly delete this message and notify the sender of the delivery error by e-mail or you may call Cerner's corporate offices in Kansas City, Missouri, U.S.A at (+1) (816)221-1024.

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: Performance test with Tomcat 9 shows increased cpu/disk usage because of repeated opening/closing of jars in WEB-INF/lib

Rhuberg,Anthony
On the other thread: Is this genuine class loading (in which case the response below is correct) or is the application reading the .class files as if they were
resources (in which case a different answer applies)?
Mostly, we are talking about the default class loader; however, the application does read resources from the jar files - mostly static files that are stored within the package structure are read (for example: log4j, property files, other static content). Would this affect the reload of the jar files?

-----Original Message-----
From: Rhuberg,Anthony
Sent: Wednesday, October 09, 2019 2:53 PM
To: Tomcat Users List <[hidden email]>
Subject: RE: Performance test with Tomcat 9 shows increased cpu/disk usage because of repeated opening/closing of jars in WEB-INF/lib

Just noticed another thread on this topic: RE: Tomcat discards and reloads the jar files from the webapps folder.

Setting the Engine attribute backgroundProcessorDelay to 90s does reduce the open/close cycle of the jars.

The other thread also mentioned a potential configuration to keep the jars open longer by default. This could be helpful - not sure we need to close them at all.

Alternatively, would there be any gain to 'explode' the jars into class files on the filesystem?

-----Original Message-----
From: Rhuberg,Anthony <[hidden email]>
Sent: Wednesday, October 09, 2019 2:17 PM
To: [hidden email]
Subject: Performance test with Tomcat 9 shows increased cpu/disk usage because of repeated opening/closing of jars in WEB-INF/lib

Background:
In the last few months we migrated our web application from Tomcat 7.0.55 to Tomcat 9.0.19 (26). That transition was relatively straightforward until we reviewed the results of our performance tests. Those tests showed an increase in CPU usage and disk I/O on our Windows 2012 server. When we switch back to Tomcat 7, the metrics for CPU/disk usage were significantly lower (similar to previous tests).

As we investigated the cause of the increase in cpu/disk usage we found the tomcat process was repeatedly opening and closing the jars of our web application. The process profile showed all the jars in WEB-INF/lib being closed and reopened within seconds while the application was processing requests (and to some extent when quite). Now we are trying to determine why.

We have a general understanding that the WebappClassLoaderBase.java implementation changed in Tomcat 8.5. The Tomcat 7 implementation provided for the configuration of  jarOpenInterval (which we used the default = 90s). The latest implementation appears to track the jar modification times with a hash map called jarModificationTimes, but we are unable to find a similar time-to-live configuration or what triggers the lifecycle listener to close the jars (what calls WebappClassLoaderBase.modified() or destroy()) - assuming we understand this lifecycle behavior.

The server is configured mostly with default settings. The Context reloadable property is NOT set. We have tried increasing the cache time of the Resources cacheTtl property as the default of 5s seemed close to the time the jars were reloaded. We have not been successful.

Question:
What is the cause of the repeated reloading of our web application jars? What can trigger the class loader to close all the file handles related to the jars in the web application WEB-INF/lib directory - and then open them again within a few seconds?



CONFIDENTIALITY NOTICE This message and any included attachments are from Cerner Corporation and are intended only for the addressee. The information contained in this message is confidential and may constitute inside or non-public information under international, federal, or state securities laws. Unauthorized forwarding, printing, copying, distribution, or use of such information is strictly prohibited and may be unlawful. If you are not the addressee, please promptly delete this message and notify the sender of the delivery error by e-mail or you may call Cerner's corporate offices in Kansas City, Missouri, U.S.A at (+1) (816)221-1024.

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Performance test with Tomcat 9 shows increased cpu/disk usage because of repeated opening/closing of jars in WEB-INF/lib

markt
On 09/10/2019 20:08, Rhuberg,Anthony wrote:
> On the other thread: Is this genuine class loading (in which case the response below is correct) or is the application reading the .class files as if they were
> resources (in which case a different answer applies)?
> Mostly, we are talking about the default class loader; however, the application does read resources from the jar files - mostly static files that are stored within the package structure are read (for example: log4j, property files, other static content). Would this affect the reload of the jar files?

If an application was reading the same resource from a JAR over and over
again, that may have a performance impact. Increasing the TTL for cached
resources would probably address that although, arguably, the better
solution in that case would be to fix the app to load it once and cache it.

> -----Original Message-----
> From: Rhuberg,Anthony
> Sent: Wednesday, October 09, 2019 2:53 PM
> To: Tomcat Users List <[hidden email]>
> Subject: RE: Performance test with Tomcat 9 shows increased cpu/disk usage because of repeated opening/closing of jars in WEB-INF/lib
>
> Just noticed another thread on this topic: RE: Tomcat discards and reloads the jar files from the webapps folder.
>
> Setting the Engine attribute backgroundProcessorDelay to 90s does reduce the open/close cycle of the jars.

Thanks for the confirmation.

> The other thread also mentioned a potential configuration to keep the jars open longer by default. This could be helpful - not sure we need to close them at all.

If the JARs aren't closed it can cause file locking issues. We could
include a disable option if we did make the Jar unload frequency
configurable.

> Alternatively, would there be any gain to 'explode' the jars into class files on the filesystem?

Maybe. Best bet it to try it for your app and see.

Mark


> -----Original Message-----
> From: Rhuberg,Anthony <[hidden email]>
> Sent: Wednesday, October 09, 2019 2:17 PM
> To: [hidden email]
> Subject: Performance test with Tomcat 9 shows increased cpu/disk usage because of repeated opening/closing of jars in WEB-INF/lib
>
> Background:
> In the last few months we migrated our web application from Tomcat 7.0.55 to Tomcat 9.0.19 (26). That transition was relatively straightforward until we reviewed the results of our performance tests. Those tests showed an increase in CPU usage and disk I/O on our Windows 2012 server. When we switch back to Tomcat 7, the metrics for CPU/disk usage were significantly lower (similar to previous tests).
>
> As we investigated the cause of the increase in cpu/disk usage we found the tomcat process was repeatedly opening and closing the jars of our web application. The process profile showed all the jars in WEB-INF/lib being closed and reopened within seconds while the application was processing requests (and to some extent when quite). Now we are trying to determine why.
>
> We have a general understanding that the WebappClassLoaderBase.java implementation changed in Tomcat 8.5. The Tomcat 7 implementation provided for the configuration of  jarOpenInterval (which we used the default = 90s). The latest implementation appears to track the jar modification times with a hash map called jarModificationTimes, but we are unable to find a similar time-to-live configuration or what triggers the lifecycle listener to close the jars (what calls WebappClassLoaderBase.modified() or destroy()) - assuming we understand this lifecycle behavior.
>
> The server is configured mostly with default settings. The Context reloadable property is NOT set. We have tried increasing the cache time of the Resources cacheTtl property as the default of 5s seemed close to the time the jars were reloaded. We have not been successful.
>
> Question:
> What is the cause of the repeated reloading of our web application jars? What can trigger the class loader to close all the file handles related to the jars in the web application WEB-INF/lib directory - and then open them again within a few seconds?
>
>
>
> CONFIDENTIALITY NOTICE This message and any included attachments are from Cerner Corporation and are intended only for the addressee. The information contained in this message is confidential and may constitute inside or non-public information under international, federal, or state securities laws. Unauthorized forwarding, printing, copying, distribution, or use of such information is strictly prohibited and may be unlawful. If you are not the addressee, please promptly delete this message and notify the sender of the delivery error by e-mail or you may call Cerner's corporate offices in Kansas City, Missouri, U.S.A at (+1) (816)221-1024.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: Performance test with Tomcat 9 shows increased cpu/disk usage because of repeated opening/closing of jars in WEB-INF/lib

Rhuberg,Anthony
In reply to this post by Rhuberg,Anthony
This seems to alleviate the issue... in context.xml (sc-test#sc.xml)
<Context docBase="${STP_HOME}/app/webapps/Clinicals" swallowOutput="true" backgroundProcessorDelay="90">

Not sure if this is the context reload trigger... i.e. the webappLoader.backgroundProcess method is triggered every 90 seconds... the reloadable property on Context is NOT set (default = false). So then how does modified() evaluate to true?
The https://github.com/apache/tomcat/blob/65aec2ac7fb4980694291e66efd360195dfa8d73/java/org/apache/catalina/loader/WebappLoader.java...
/**
     * Execute a periodic task, such as reloading, etc. This method will be
     * invoked inside the classloading context of this container. Unexpected
     * throwables will be caught and logged.
     */
    @Override
    public void backgroundProcess() {
        if (reloadable && modified()) {
            try {
                Thread.currentThread().setContextClassLoader
                    (WebappLoader.class.getClassLoader());
                if (context != null) {
                    context.reload();
                }
            } finally {
                if (context != null && context.getLoader() != null) {
                    Thread.currentThread().setContextClassLoader
                        (context.getLoader().getClassLoader());
                }
            }
        }
    }

I do not understand how modified = true. Why would the jar date/time be changed?
https://github.com/apache/tomcat/blob/8.5.x/java/org/apache/catalina/loader/WebappClassLoaderBase.java
/**
     * Have one or more classes or resources been modified so that a reload
     * is appropriate?
     * @return <code>true</code> if there's been a modification
     */
    public boolean modified() {

        if (log.isDebugEnabled())
            log.debug("modified()");

        for (Entry<String,ResourceEntry> entry : resourceEntries.entrySet()) {
            long cachedLastModified = entry.getValue().lastModified;
            long lastModified = resources.getClassLoaderResource(
                    entry.getKey()).getLastModified();
            if (lastModified != cachedLastModified) {
                if( log.isDebugEnabled() )
                    log.debug(sm.getString("webappClassLoader.resourceModified",
                            entry.getKey(),
                            new Date(cachedLastModified),
                            new Date(lastModified)));
                return true;
            }
        }

        // Check if JARs have been added or removed
        WebResource[] jars = resources.listResources("/WEB-INF/lib");
        // Filter out non-JAR resources

        int jarCount = 0;
        for (WebResource jar : jars) {
            if (jar.getName().endsWith(".jar") && jar.isFile() && jar.canRead()) {
                jarCount++;
                Long recordedLastModified = jarModificationTimes.get(jar.getName());
                if (recordedLastModified == null) {
                    // Jar has been added
                    log.info(sm.getString("webappClassLoader.jarsAdded",
                            resources.getContext().getName()));
                    return true;
                }
                if (recordedLastModified.longValue() != jar.getLastModified()) {
                    // Jar has been changed
                    log.info(sm.getString("webappClassLoader.jarsModified",
                            resources.getContext().getName()));
                    return true;
                }
            }
        }

        if (jarCount < jarModificationTimes.size()){
            log.info(sm.getString("webappClassLoader.jarsRemoved",
                    resources.getContext().getName()));
            return true;
        }


        // No classes have been modified
        return false;
    }

-----Original Message-----
From: Rhuberg,Anthony
Sent: Wednesday, October 09, 2019 3:08 PM
To: Tomcat Users List <[hidden email]>
Subject: RE: Performance test with Tomcat 9 shows increased cpu/disk usage because of repeated opening/closing of jars in WEB-INF/lib

On the other thread: Is this genuine class loading (in which case the response below is correct) or is the application reading the .class files as if they were resources (in which case a different answer applies)?
Mostly, we are talking about the default class loader; however, the application does read resources from the jar files - mostly static files that are stored within the package structure are read (for example: log4j, property files, other static content). Would this affect the reload of the jar files?

-----Original Message-----
From: Rhuberg,Anthony
Sent: Wednesday, October 09, 2019 2:53 PM
To: Tomcat Users List <[hidden email]>
Subject: RE: Performance test with Tomcat 9 shows increased cpu/disk usage because of repeated opening/closing of jars in WEB-INF/lib

Just noticed another thread on this topic: RE: Tomcat discards and reloads the jar files from the webapps folder.

Setting the Engine attribute backgroundProcessorDelay to 90s does reduce the open/close cycle of the jars.

The other thread also mentioned a potential configuration to keep the jars open longer by default. This could be helpful - not sure we need to close them at all.

Alternatively, would there be any gain to 'explode' the jars into class files on the filesystem?

-----Original Message-----
From: Rhuberg,Anthony <[hidden email]>
Sent: Wednesday, October 09, 2019 2:17 PM
To: [hidden email]
Subject: Performance test with Tomcat 9 shows increased cpu/disk usage because of repeated opening/closing of jars in WEB-INF/lib

Background:
In the last few months we migrated our web application from Tomcat 7.0.55 to Tomcat 9.0.19 (26). That transition was relatively straightforward until we reviewed the results of our performance tests. Those tests showed an increase in CPU usage and disk I/O on our Windows 2012 server. When we switch back to Tomcat 7, the metrics for CPU/disk usage were significantly lower (similar to previous tests).

As we investigated the cause of the increase in cpu/disk usage we found the tomcat process was repeatedly opening and closing the jars of our web application. The process profile showed all the jars in WEB-INF/lib being closed and reopened within seconds while the application was processing requests (and to some extent when quite). Now we are trying to determine why.

We have a general understanding that the WebappClassLoaderBase.java implementation changed in Tomcat 8.5. The Tomcat 7 implementation provided for the configuration of  jarOpenInterval (which we used the default = 90s). The latest implementation appears to track the jar modification times with a hash map called jarModificationTimes, but we are unable to find a similar time-to-live configuration or what triggers the lifecycle listener to close the jars (what calls WebappClassLoaderBase.modified() or destroy()) - assuming we understand this lifecycle behavior.

The server is configured mostly with default settings. The Context reloadable property is NOT set. We have tried increasing the cache time of the Resources cacheTtl property as the default of 5s seemed close to the time the jars were reloaded. We have not been successful.

Question:
What is the cause of the repeated reloading of our web application jars? What can trigger the class loader to close all the file handles related to the jars in the web application WEB-INF/lib directory - and then open them again within a few seconds?



CONFIDENTIALITY NOTICE This message and any included attachments are from Cerner Corporation and are intended only for the addressee. The information contained in this message is confidential and may constitute inside or non-public information under international, federal, or state securities laws. Unauthorized forwarding, printing, copying, distribution, or use of such information is strictly prohibited and may be unlawful. If you are not the addressee, please promptly delete this message and notify the sender of the delivery error by e-mail or you may call Cerner's corporate offices in Kansas City, Missouri, U.S.A at (+1) (816)221-1024.

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: Performance test with Tomcat 9 shows increased cpu/disk usage because of repeated opening/closing of jars in WEB-INF/lib

Rhuberg,Anthony
In reply to this post by markt
Thanks for your responses.

I understand that re-reading the static files is not optimal, but how does reading files from the jar affect them being reloaded... In Tomcat 7, that seemed to prevent the jars from being reloaded since the accessTime was changed; in Tomcat 8, it seems the modified() method uses the file modified time - not sure what we are doing to cause the modified time to change - the files on the filesystem are not changing - unless there is something happening in the classes folder.

Thanks

-----Original Message-----
From: Mark Thomas <[hidden email]>
Sent: Wednesday, October 09, 2019 3:56 PM
To: [hidden email]
Subject: Re: Performance test with Tomcat 9 shows increased cpu/disk usage because of repeated opening/closing of jars in WEB-INF/lib

On 09/10/2019 20:08, Rhuberg,Anthony wrote:
> On the other thread: Is this genuine class loading (in which case the
> response below is correct) or is the application reading the .class files as if they were resources (in which case a different answer applies)?
> Mostly, we are talking about the default class loader; however, the application does read resources from the jar files - mostly static files that are stored within the package structure are read (for example: log4j, property files, other static content). Would this affect the reload of the jar files?

If an application was reading the same resource from a JAR over and over again, that may have a performance impact. Increasing the TTL for cached resources would probably address that although, arguably, the better solution in that case would be to fix the app to load it once and cache it.

> -----Original Message-----
> From: Rhuberg,Anthony
> Sent: Wednesday, October 09, 2019 2:53 PM
> To: Tomcat Users List <[hidden email]>
> Subject: RE: Performance test with Tomcat 9 shows increased cpu/disk
> usage because of repeated opening/closing of jars in WEB-INF/lib
>
> Just noticed another thread on this topic: RE: Tomcat discards and reloads the jar files from the webapps folder.
>
> Setting the Engine attribute backgroundProcessorDelay to 90s does reduce the open/close cycle of the jars.

Thanks for the confirmation.

> The other thread also mentioned a potential configuration to keep the jars open longer by default. This could be helpful - not sure we need to close them at all.

If the JARs aren't closed it can cause file locking issues. We could include a disable option if we did make the Jar unload frequency configurable.

> Alternatively, would there be any gain to 'explode' the jars into class files on the filesystem?

Maybe. Best bet it to try it for your app and see.

Mark


> -----Original Message-----
> From: Rhuberg,Anthony <[hidden email]>
> Sent: Wednesday, October 09, 2019 2:17 PM
> To: [hidden email]
> Subject: Performance test with Tomcat 9 shows increased cpu/disk usage
> because of repeated opening/closing of jars in WEB-INF/lib
>
> Background:
> In the last few months we migrated our web application from Tomcat 7.0.55 to Tomcat 9.0.19 (26). That transition was relatively straightforward until we reviewed the results of our performance tests. Those tests showed an increase in CPU usage and disk I/O on our Windows 2012 server. When we switch back to Tomcat 7, the metrics for CPU/disk usage were significantly lower (similar to previous tests).
>
> As we investigated the cause of the increase in cpu/disk usage we found the tomcat process was repeatedly opening and closing the jars of our web application. The process profile showed all the jars in WEB-INF/lib being closed and reopened within seconds while the application was processing requests (and to some extent when quite). Now we are trying to determine why.
>
> We have a general understanding that the WebappClassLoaderBase.java implementation changed in Tomcat 8.5. The Tomcat 7 implementation provided for the configuration of  jarOpenInterval (which we used the default = 90s). The latest implementation appears to track the jar modification times with a hash map called jarModificationTimes, but we are unable to find a similar time-to-live configuration or what triggers the lifecycle listener to close the jars (what calls WebappClassLoaderBase.modified() or destroy()) - assuming we understand this lifecycle behavior.
>
> The server is configured mostly with default settings. The Context reloadable property is NOT set. We have tried increasing the cache time of the Resources cacheTtl property as the default of 5s seemed close to the time the jars were reloaded. We have not been successful.
>
> Question:
> What is the cause of the repeated reloading of our web application jars? What can trigger the class loader to close all the file handles related to the jars in the web application WEB-INF/lib directory - and then open them again within a few seconds?
>
>
>
> CONFIDENTIALITY NOTICE This message and any included attachments are from Cerner Corporation and are intended only for the addressee. The information contained in this message is confidential and may constitute inside or non-public information under international, federal, or state securities laws. Unauthorized forwarding, printing, copying, distribution, or use of such information is strictly prohibited and may be unlawful. If you are not the addressee, please promptly delete this message and notify the sender of the delivery error by e-mail or you may call Cerner's corporate offices in Kansas City, Missouri, U.S.A at (+1) (816)221-1024.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Performance test with Tomcat 9 shows increased cpu/disk usage because of repeated opening/closing of jars in WEB-INF/lib

Paul Carter-Brown
Hi Anthony

Have you turned debug logging on to see what it is picking up as modified?

On Wed, 09 Oct 2019, 22:24 Rhuberg,Anthony,
<[hidden email]> wrote:

> Thanks for your responses.
>
> I understand that re-reading the static files is not optimal, but how does
> reading files from the jar affect them being reloaded... In Tomcat 7, that
> seemed to prevent the jars from being reloaded since the accessTime was
> changed; in Tomcat 8, it seems the modified() method uses the file modified
> time - not sure what we are doing to cause the modified time to change -
> the files on the filesystem are not changing - unless there is something
> happening in the classes folder.
>
> Thanks
>
> -----Original Message-----
> From: Mark Thomas <[hidden email]>
> Sent: Wednesday, October 09, 2019 3:56 PM
> To: [hidden email]
> Subject: Re: Performance test with Tomcat 9 shows increased cpu/disk usage
> because of repeated opening/closing of jars in WEB-INF/lib
>
> On 09/10/2019 20:08, Rhuberg,Anthony wrote:
> > On the other thread: Is this genuine class loading (in which case the
> > response below is correct) or is the application reading the .class
> files as if they were resources (in which case a different answer applies)?
> > Mostly, we are talking about the default class loader; however, the
> application does read resources from the jar files - mostly static files
> that are stored within the package structure are read (for example: log4j,
> property files, other static content). Would this affect the reload of the
> jar files?
>
> If an application was reading the same resource from a JAR over and over
> again, that may have a performance impact. Increasing the TTL for cached
> resources would probably address that although, arguably, the better
> solution in that case would be to fix the app to load it once and cache it.
>
> > -----Original Message-----
> > From: Rhuberg,Anthony
> > Sent: Wednesday, October 09, 2019 2:53 PM
> > To: Tomcat Users List <[hidden email]>
> > Subject: RE: Performance test with Tomcat 9 shows increased cpu/disk
> > usage because of repeated opening/closing of jars in WEB-INF/lib
> >
> > Just noticed another thread on this topic: RE: Tomcat discards and
> reloads the jar files from the webapps folder.
> >
> > Setting the Engine attribute backgroundProcessorDelay to 90s does reduce
> the open/close cycle of the jars.
>
> Thanks for the confirmation.
>
> > The other thread also mentioned a potential configuration to keep the
> jars open longer by default. This could be helpful - not sure we need to
> close them at all.
>
> If the JARs aren't closed it can cause file locking issues. We could
> include a disable option if we did make the Jar unload frequency
> configurable.
>
> > Alternatively, would there be any gain to 'explode' the jars into class
> files on the filesystem?
>
> Maybe. Best bet it to try it for your app and see.
>
> Mark
>
>
> > -----Original Message-----
> > From: Rhuberg,Anthony <[hidden email]>
> > Sent: Wednesday, October 09, 2019 2:17 PM
> > To: [hidden email]
> > Subject: Performance test with Tomcat 9 shows increased cpu/disk usage
> > because of repeated opening/closing of jars in WEB-INF/lib
> >
> > Background:
> > In the last few months we migrated our web application from Tomcat
> 7.0.55 to Tomcat 9.0.19 (26). That transition was relatively
> straightforward until we reviewed the results of our performance tests.
> Those tests showed an increase in CPU usage and disk I/O on our Windows
> 2012 server. When we switch back to Tomcat 7, the metrics for CPU/disk
> usage were significantly lower (similar to previous tests).
> >
> > As we investigated the cause of the increase in cpu/disk usage we found
> the tomcat process was repeatedly opening and closing the jars of our web
> application. The process profile showed all the jars in WEB-INF/lib being
> closed and reopened within seconds while the application was processing
> requests (and to some extent when quite). Now we are trying to determine
> why.
> >
> > We have a general understanding that the WebappClassLoaderBase.java
> implementation changed in Tomcat 8.5. The Tomcat 7 implementation provided
> for the configuration of  jarOpenInterval (which we used the default =
> 90s). The latest implementation appears to track the jar modification times
> with a hash map called jarModificationTimes, but we are unable to find a
> similar time-to-live configuration or what triggers the lifecycle listener
> to close the jars (what calls WebappClassLoaderBase.modified() or
> destroy()) - assuming we understand this lifecycle behavior.
> >
> > The server is configured mostly with default settings. The Context
> reloadable property is NOT set. We have tried increasing the cache time of
> the Resources cacheTtl property as the default of 5s seemed close to the
> time the jars were reloaded. We have not been successful.
> >
> > Question:
> > What is the cause of the repeated reloading of our web application jars?
> What can trigger the class loader to close all the file handles related to
> the jars in the web application WEB-INF/lib directory - and then open them
> again within a few seconds?
> >
> >
> >
> > CONFIDENTIALITY NOTICE This message and any included attachments are
> from Cerner Corporation and are intended only for the addressee. The
> information contained in this message is confidential and may constitute
> inside or non-public information under international, federal, or state
> securities laws. Unauthorized forwarding, printing, copying, distribution,
> or use of such information is strictly prohibited and may be unlawful. If
> you are not the addressee, please promptly delete this message and notify
> the sender of the delivery error by e-mail or you may call Cerner's
> corporate offices in Kansas City, Missouri, U.S.A at (+1) (816)221-1024.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]
> > For additional commands, e-mail: [hidden email]
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]
> > For additional commands, e-mail: [hidden email]
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Performance test with Tomcat 9 shows increased cpu/disk usage because of repeated opening/closing of jars in WEB-INF/lib

markt
In reply to this post by Rhuberg,Anthony
On 09/10/2019 21:03, Rhuberg,Anthony wrote:
> This seems to alleviate the issue... in context.xml (sc-test#sc.xml)
> <Context docBase="${STP_HOME}/app/webapps/Clinicals" swallowOutput="true" backgroundProcessorDelay="90">
>
> Not sure if this is the context reload trigger... i.e. the webappLoader.backgroundProcess method is triggered every 90 seconds...

It isn't. It is StandardRoot.gc() that is unloading the cached JAR entries.

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: Performance test with Tomcat 9 shows increased cpu/disk usage because of repeated opening/closing of jars in WEB-INF/lib

Rhuberg,Anthony
In reply to this post by Paul Carter-Brown
I have not seen the trace message for modified()... So my understanding of this is wrong.

-----Original Message-----
From: Paul Carter-Brown <[hidden email]>
Sent: Wednesday, October 09, 2019 4:42 PM
To: Tomcat Users List <[hidden email]>
Subject: Re: Performance test with Tomcat 9 shows increased cpu/disk usage because of repeated opening/closing of jars in WEB-INF/lib

Hi Anthony

Have you turned debug logging on to see what it is picking up as modified?

On Wed, 09 Oct 2019, 22:24 Rhuberg,Anthony, <[hidden email]> wrote:

> Thanks for your responses.
>
> I understand that re-reading the static files is not optimal, but how
> does reading files from the jar affect them being reloaded... In
> Tomcat 7, that seemed to prevent the jars from being reloaded since
> the accessTime was changed; in Tomcat 8, it seems the modified()
> method uses the file modified time - not sure what we are doing to
> cause the modified time to change - the files on the filesystem are
> not changing - unless there is something happening in the classes folder.
>
> Thanks
>
> -----Original Message-----
> From: Mark Thomas <[hidden email]>
> Sent: Wednesday, October 09, 2019 3:56 PM
> To: [hidden email]
> Subject: Re: Performance test with Tomcat 9 shows increased cpu/disk
> usage because of repeated opening/closing of jars in WEB-INF/lib
>
> On 09/10/2019 20:08, Rhuberg,Anthony wrote:
> > On the other thread: Is this genuine class loading (in which case
> > the response below is correct) or is the application reading the
> > .class
> files as if they were resources (in which case a different answer applies)?
> > Mostly, we are talking about the default class loader; however, the
> application does read resources from the jar files - mostly static
> files that are stored within the package structure are read (for
> example: log4j, property files, other static content). Would this
> affect the reload of the jar files?
>
> If an application was reading the same resource from a JAR over and
> over again, that may have a performance impact. Increasing the TTL for
> cached resources would probably address that although, arguably, the
> better solution in that case would be to fix the app to load it once and cache it.
>
> > -----Original Message-----
> > From: Rhuberg,Anthony
> > Sent: Wednesday, October 09, 2019 2:53 PM
> > To: Tomcat Users List <[hidden email]>
> > Subject: RE: Performance test with Tomcat 9 shows increased cpu/disk
> > usage because of repeated opening/closing of jars in WEB-INF/lib
> >
> > Just noticed another thread on this topic: RE: Tomcat discards and
> reloads the jar files from the webapps folder.
> >
> > Setting the Engine attribute backgroundProcessorDelay to 90s does
> > reduce
> the open/close cycle of the jars.
>
> Thanks for the confirmation.
>
> > The other thread also mentioned a potential configuration to keep
> > the
> jars open longer by default. This could be helpful - not sure we need
> to close them at all.
>
> If the JARs aren't closed it can cause file locking issues. We could
> include a disable option if we did make the Jar unload frequency
> configurable.
>
> > Alternatively, would there be any gain to 'explode' the jars into
> > class
> files on the filesystem?
>
> Maybe. Best bet it to try it for your app and see.
>
> Mark
>
>
> > -----Original Message-----
> > From: Rhuberg,Anthony <[hidden email]>
> > Sent: Wednesday, October 09, 2019 2:17 PM
> > To: [hidden email]
> > Subject: Performance test with Tomcat 9 shows increased cpu/disk
> > usage because of repeated opening/closing of jars in WEB-INF/lib
> >
> > Background:
> > In the last few months we migrated our web application from Tomcat
> 7.0.55 to Tomcat 9.0.19 (26). That transition was relatively
> straightforward until we reviewed the results of our performance tests.
> Those tests showed an increase in CPU usage and disk I/O on our
> Windows
> 2012 server. When we switch back to Tomcat 7, the metrics for CPU/disk
> usage were significantly lower (similar to previous tests).
> >
> > As we investigated the cause of the increase in cpu/disk usage we
> > found
> the tomcat process was repeatedly opening and closing the jars of our
> web application. The process profile showed all the jars in
> WEB-INF/lib being closed and reopened within seconds while the
> application was processing requests (and to some extent when quite).
> Now we are trying to determine why.
> >
> > We have a general understanding that the WebappClassLoaderBase.java
> implementation changed in Tomcat 8.5. The Tomcat 7 implementation
> provided for the configuration of  jarOpenInterval (which we used the
> default = 90s). The latest implementation appears to track the jar
> modification times with a hash map called jarModificationTimes, but we
> are unable to find a similar time-to-live configuration or what
> triggers the lifecycle listener to close the jars (what calls
> WebappClassLoaderBase.modified() or
> destroy()) - assuming we understand this lifecycle behavior.
> >
> > The server is configured mostly with default settings. The Context
> reloadable property is NOT set. We have tried increasing the cache
> time of the Resources cacheTtl property as the default of 5s seemed
> close to the time the jars were reloaded. We have not been successful.
> >
> > Question:
> > What is the cause of the repeated reloading of our web application jars?
> What can trigger the class loader to close all the file handles
> related to the jars in the web application WEB-INF/lib directory - and
> then open them again within a few seconds?
> >
> >
> >
> > CONFIDENTIALITY NOTICE This message and any included attachments are
> from Cerner Corporation and are intended only for the addressee. The
> information contained in this message is confidential and may
> constitute inside or non-public information under international,
> federal, or state securities laws. Unauthorized forwarding, printing,
> copying, distribution, or use of such information is strictly
> prohibited and may be unlawful. If you are not the addressee, please
> promptly delete this message and notify the sender of the delivery
> error by e-mail or you may call Cerner's corporate offices in Kansas City, Missouri, U.S.A at (+1) (816)221-1024.
> >
> > --------------------------------------------------------------------
> > - To unsubscribe, e-mail: [hidden email]
> > For additional commands, e-mail: [hidden email]
> >
> >
> > --------------------------------------------------------------------
> > - To unsubscribe, e-mail: [hidden email]
> > For additional commands, e-mail: [hidden email]
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>


CONFIDENTIALITY NOTICE This message and any included attachments are from Cerner Corporation and are intended only for the addressee. The information contained in this message is confidential and may constitute inside or non-public information under international, federal, or state securities laws. Unauthorized forwarding, printing, copying, distribution, or use of such information is strictly prohibited and may be unlawful. If you are not the addressee, please promptly delete this message and notify the sender of the delivery error by e-mail or you may call Cerner's corporate offices in Kansas City, Missouri, U.S.A at (+1) (816)221-1024.

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]
Reply | Threaded
Open this post in threaded view
|

RE: Performance test with Tomcat 9 shows increased cpu/disk usage because of repeated opening/closing of jars in WEB-INF/lib

Rhuberg,Anthony
In reply to this post by markt
StandardRoot.gc() unconditionally closes the web application jars in Tomcat 9... every 10s by default or configurable by changing backgroundProcessorDelay.

So then the problem is.... Our web application is calling class.getResourceAsStream() to read some static files... and this is causing the jars to be read again? This was not a problem with Tomcat 7 because the jars were not closed if they were read within the jarOpenInterval setting?

Thanks,
Tony

-----Original Message-----
From: Mark Thomas <[hidden email]>
Sent: Wednesday, October 09, 2019 5:32 PM
To: [hidden email]
Subject: Re: Performance test with Tomcat 9 shows increased cpu/disk usage because of repeated opening/closing of jars in WEB-INF/lib

On 09/10/2019 21:03, Rhuberg,Anthony wrote:
> This seems to alleviate the issue... in context.xml (sc-test#sc.xml)
> <Context docBase="${STP_HOME}/app/webapps/Clinicals"
> swallowOutput="true" backgroundProcessorDelay="90">
>
> Not sure if this is the context reload trigger... i.e. the webappLoader.backgroundProcess method is triggered every 90 seconds...

It isn't. It is StandardRoot.gc() that is unloading the cached JAR entries.

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]



CONFIDENTIALITY NOTICE This message and any included attachments are from Cerner Corporation and are intended only for the addressee. The information contained in this message is confidential and may constitute inside or non-public information under international, federal, or state securities laws. Unauthorized forwarding, printing, copying, distribution, or use of such information is strictly prohibited and may be unlawful. If you are not the addressee, please promptly delete this message and notify the sender of the delivery error by e-mail or you may call Cerner's corporate offices in Kansas City, Missouri, U.S.A at (+1) (816)221-1024.

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Performance test with Tomcat 9 shows increased cpu/disk usage because of repeated opening/closing of jars in WEB-INF/lib

markt
On 09/10/2019 22:58, Rhuberg,Anthony wrote:
> StandardRoot.gc() unconditionally closes the web application jars in Tomcat 9... every 10s by default or configurable by changing backgroundProcessorDelay.
>
> So then the problem is.... Our web application is calling class.getResourceAsStream() to read some static files... and this is causing the jars to be read again?

It sounds like it.

> This was not a problem with Tomcat 7 because the jars were not closed if they were read within the jarOpenInterval setting?

Or that the frequency that the JARs were closed was low enough that the
performance impact was not noticed.

Mark


>
> Thanks,
> Tony
>
> -----Original Message-----
> From: Mark Thomas <[hidden email]>
> Sent: Wednesday, October 09, 2019 5:32 PM
> To: [hidden email]
> Subject: Re: Performance test with Tomcat 9 shows increased cpu/disk usage because of repeated opening/closing of jars in WEB-INF/lib
>
> On 09/10/2019 21:03, Rhuberg,Anthony wrote:
>> This seems to alleviate the issue... in context.xml (sc-test#sc.xml)
>> <Context docBase="${STP_HOME}/app/webapps/Clinicals"
>> swallowOutput="true" backgroundProcessorDelay="90">
>>
>> Not sure if this is the context reload trigger... i.e. the webappLoader.backgroundProcess method is triggered every 90 seconds...
>
> It isn't. It is StandardRoot.gc() that is unloading the cached JAR entries.
>
> Mark
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
>
> CONFIDENTIALITY NOTICE This message and any included attachments are from Cerner Corporation and are intended only for the addressee. The information contained in this message is confidential and may constitute inside or non-public information under international, federal, or state securities laws. Unauthorized forwarding, printing, copying, distribution, or use of such information is strictly prohibited and may be unlawful. If you are not the addressee, please promptly delete this message and notify the sender of the delivery error by e-mail or you may call Cerner's corporate offices in Kansas City, Missouri, U.S.A at (+1) (816)221-1024.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: Performance test with Tomcat 9 shows increased cpu/disk usage because of repeated opening/closing of jars in WEB-INF/lib

Rhuberg,Anthony
We are still investigating what specific classloader reads that would trigger the repeated reload of the web-inf/lib/*.jars.

One example we found is the use of javax.xml.transform.TransformerFactory.newInstance(). One of its features is to determine the implementation by searching for the configuration specified by META-INF/services/javax.xml.transform.TransformerFactory in jars available to the runtime.

It seems users of Tomcat 9 would need to understand the management of the jar resource handles when using the TransformerFactory class - assuming it is triggering the reload of all the related application jars - which if happening enough can cause the high cpu/disk usage as we observed in our performance tests.

Thanks

-----Original Message-----
From: Mark Thomas <[hidden email]>
Sent: Thursday, October 10, 2019 3:54 AM
To: [hidden email]
Subject: Re: Performance test with Tomcat 9 shows increased cpu/disk usage because of repeated opening/closing of jars in WEB-INF/lib

On 09/10/2019 22:58, Rhuberg,Anthony wrote:
> StandardRoot.gc() unconditionally closes the web application jars in Tomcat 9... every 10s by default or configurable by changing backgroundProcessorDelay.
>
> So then the problem is.... Our web application is calling class.getResourceAsStream() to read some static files... and this is causing the jars to be read again?

It sounds like it.

> This was not a problem with Tomcat 7 because the jars were not closed if they were read within the jarOpenInterval setting?

Or that the frequency that the JARs were closed was low enough that the performance impact was not noticed.

Mark


>
> Thanks,
> Tony
>
> -----Original Message-----
> From: Mark Thomas <[hidden email]>
> Sent: Wednesday, October 09, 2019 5:32 PM
> To: [hidden email]
> Subject: Re: Performance test with Tomcat 9 shows increased cpu/disk
> usage because of repeated opening/closing of jars in WEB-INF/lib
>
> On 09/10/2019 21:03, Rhuberg,Anthony wrote:
>> This seems to alleviate the issue... in context.xml (sc-test#sc.xml)
>> <Context docBase="${STP_HOME}/app/webapps/Clinicals"
>> swallowOutput="true" backgroundProcessorDelay="90">
>>
>> Not sure if this is the context reload trigger... i.e. the webappLoader.backgroundProcess method is triggered every 90 seconds...
>
> It isn't. It is StandardRoot.gc() that is unloading the cached JAR entries.
>
> Mark
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
>
> CONFIDENTIALITY NOTICE This message and any included attachments are from Cerner Corporation and are intended only for the addressee. The information contained in this message is confidential and may constitute inside or non-public information under international, federal, or state securities laws. Unauthorized forwarding, printing, copying, distribution, or use of such information is strictly prohibited and may be unlawful. If you are not the addressee, please promptly delete this message and notify the sender of the delivery error by e-mail or you may call Cerner's corporate offices in Kansas City, Missouri, U.S.A at (+1) (816)221-1024.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]
Reply | Threaded
Open this post in threaded view
|

RE: Performance test with Tomcat 9 shows increased cpu/disk usage because of repeated opening/closing of jars in WEB-INF/lib

John.E.Gregg-2
Tony,


> -----Original Message-----
> From: Rhuberg,Anthony <[hidden email]>
> Sent: Thursday, October 10, 2019 5:22 PM
> To: Tomcat Users List <[hidden email]>
> Subject: RE: Performance test with Tomcat 9 shows increased cpu/disk usage
> because of repeated opening/closing of jars in WEB-INF/lib
>
> We are still investigating what specific classloader reads that would trigger
> the repeated reload of the web-inf/lib/*.jars.
>
> One example we found is the use of
> javax.xml.transform.TransformerFactory.newInstance(). One of its features
> is to determine the implementation by searching for the configuration
> specified by META-INF/services/javax.xml.transform.TransformerFactory in
> jars available to the runtime.
>

Yep.  I was wondering about that.  I have no idea why this behavior would be different in Tomcat 9, though.  Did you change Java versions also?  Is the classpath longer?

I also have no idea about the jar modification date changes that you're seeing.

I do have first-hand experience with the performance of TransformerFactory.newInstance().  In general, anything that uses the service locator under the covers, such as TransformerFactory, DocumentBuilderFactory, etc, should be reused if possible.  Those XML factories are thread safe, though the things created by the factories are typically not thread safe.  You should create it once, configure it once, and use it as many times as necessary.  For example, you would create one TransformerFactory, then call newTransformer() as many times as necessary.

John

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]
Reply | Threaded
Open this post in threaded view
|

RE: Performance test with Tomcat 9 shows increased cpu/disk usage because of repeated opening/closing of jars in WEB-INF/lib

Rhuberg,Anthony
We continue to profile our application and have found instances of using TransformerFactory.newInstance().

The more concerning problem is third party dependencies that do this or something similar we could not fix.

Jar modified times are not changing - I did not mean to state or otherwise imply that.

-----Original Message-----
From: [hidden email] <[hidden email]>
Sent: Thursday, October 10, 2019 6:54 PM
To: [hidden email]
Subject: RE: Performance test with Tomcat 9 shows increased cpu/disk usage because of repeated opening/closing of jars in WEB-INF/lib

Tony,


> -----Original Message-----
> From: Rhuberg,Anthony <[hidden email]>
> Sent: Thursday, October 10, 2019 5:22 PM
> To: Tomcat Users List <[hidden email]>
> Subject: RE: Performance test with Tomcat 9 shows increased cpu/disk
> usage because of repeated opening/closing of jars in WEB-INF/lib
>
> We are still investigating what specific classloader reads that would
> trigger the repeated reload of the web-inf/lib/*.jars.
>
> One example we found is the use of
> javax.xml.transform.TransformerFactory.newInstance(). One of its
> features is to determine the implementation by searching for the
> configuration specified by
> META-INF/services/javax.xml.transform.TransformerFactory in jars available to the runtime.
>

Yep.  I was wondering about that.  I have no idea why this behavior would be different in Tomcat 9, though.  Did you change Java versions also?  Is the classpath longer?

I also have no idea about the jar modification date changes that you're seeing.

I do have first-hand experience with the performance of TransformerFactory.newInstance().  In general, anything that uses the service locator under the covers, such as TransformerFactory, DocumentBuilderFactory, etc, should be reused if possible.  Those XML factories are thread safe, though the things created by the factories are typically not thread safe.  You should create it once, configure it once, and use it as many times as necessary.  For example, you would create one TransformerFactory, then call newTransformer() as many times as necessary.

John
B KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKCB  [  X  ܚX KK[XZ[
 \ \  ][  X  ܚX P X ]
 \X K ܙ B  ܈Y][ۘ[  [X[  K[XZ[
 \ \  Z[ X ]
 \X K ܙ B


CONFIDENTIALITY NOTICE This message and any included attachments are from Cerner Corporation and are intended only for the addressee. The information contained in this message is confidential and may constitute inside or non-public information under international, federal, or state securities laws. Unauthorized forwarding, printing, copying, distribution, or use of such information is strictly prohibited and may be unlawful. If you are not the addressee, please promptly delete this message and notify the sender of the delivery error by e-mail or you may call Cerner's corporate offices in Kansas City, Missouri, U.S.A at (+1) (816)221-1024.

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]