ср, 29 мая 2024 г. в 13:34, Mark Thomas <ma...@apache.org>:
>
>
>
> It is also problem number 3. The reason it is expensive is that class
> loaders don't cache misses so if a web application has a large number of
> JARs, they all get scanned every time the DriverManager tries to create
> a new connection.
>
>
> The slowness occurs in the web application that depends on the second
> JDBC driver in DriverManager's list. When a request that requires a
> database connection is received, there is a short delay while the web
> application tries, and fails, to load the first JDBC driver in the list.
> Class loading is synchronized on class name being loaded so if any other
> requests also need a database connection, they have to wait for this
> request to finish the search for the JDBC driver before they can
> continue. This creates a bottleneck. Requests are essentially rate
> limited to 1 request that requires a database connection per however
> long it takes to scan every JAR in the web application for a class that
> isn't there. If the average rate of requests exceeds this rate limit
> then a queue is going to build up and it won't subside until the average
> rate of requests falls below this rate limit.
>
> [...]
>
> Problem number 3 is a Tomcat issue. It should be relatively easy to
> start caching misses (i.e. this class loader cannot load this class) and
> save the time spent repeatedly scanning JARs for a class that isn't there.
>

(I wonder if unpacking all JARs into the WEB-INF/classes directory will help.)

> Something to try while I work on a patch is setting
> archiveIndexStrategy="bloom" on the resources.
>
> You'd configure that in META-INF/context.xml something like this:
>
> <Context>
>    <Resources archiveIndexStrategy="bloom" />
> </Context>

+1 for archiveIndexStrategy="bloom".

https://tomcat.apache.org/tomcat-9.0-doc/config/resources.html

The option is available since Tomcat 9.0.69 and thus should be OK here.
(Earlier versions had the feature since 9.0.39, but it was configured
through an attribute of Context
https://bz.apache.org/bugzilla/show_bug.cgi?id=66209

Best regards,
Konstantin Kolinko

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to