To whom it may concern,

On 4/18/22 23:55, z...@sina.com wrote:
Tomcat version: 
9.0.62https://github.com/apache/tomcat/blob/9.0.62/java/org/apache/tomcat/util/threads/TaskQueue.java#L116
         //if we have less threads than maximum force creation of a new thread     
   if (parent.getPoolSize()<parent.getMaximumPoolSize()) {            return 
false;        }

we have set sever.tomcat.max-threads=300 for the embedded tomcat server in our 
app, but the number of http-nio-xxx-exec threads will be 500+ which will cause 
JVM free memory exhausted under pressure tesing.it seemed that all 
org.apache.tomcat.util.threads.TaskQueue#offer calling return false if more 
than 300 requests are accepted at the same time.

Can you please post more of your code? Are you using a single Connector? You have "xxx" in your thread name which may mean that (a) you don't want to disclose your port number (okay) or (b) you have multiple Connectors with different port numbers.

Tomcat doesn't have a "server.tomcat.max-threads" setting, so your embedded driver must be applying that setting somewhere. That setting it likely applied per-Connector.

If you want to limit the total number of threads used by *all* Connectors together, you will have to configure an Executor which is shared by all of your Connectors.

To answer the question posed in the subject, TaskQueue extends LinkedBlockingQueue and most calls to TaskQueue.offer end up calling super.offer which provides the necessary thread-safety.

-chris

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

Reply via email to