Rick,

On 3/27/24 07:53, Rick Noel wrote:
I was wondering if the apache foundation has any tools we can use to
fine tune Tomcat 10. Tools to deteming how to set the best heap size
for Tomcat startup and the best connection attributes of
minSpareThreads and MaxThreads.
What is your goal?

I know my application at times will reach 100 concurrent connections
> and some times goes has high as 500 connections.

Okay.

Should I boost minSpareThreads and maxThread values of what I plan to
use below? >
Or why would we not just set very high minSpareThreads and maxThread values
like minSpareThreads =300  and maxThread=1000

This is a snippet of my server.xml

<Executor  name="tomcatPhoneAppThreadPool"  namePrefix="catalina-executor-"
                 minSpareThreads="50"
                   maxThreads="300"    />

       <Connector port="8585"
                      executor="tomcatPhoneAppThreadPool"
                      compression="on"
                      compressionMinSize="2048"
                      
compressableMimeType="text/html,text/xml,text/plain,text/css,text/javascript,application/javascript,application/json,application/xml"
                      protocol="org.apache.coyote.http11.Http11NioProtocol"
                                    redirectPort="8443">
                                        <UpgradeProtocol 
className="org.apache.coyote.http2.Http2Protocol" />

          </Connector>

Also, am I good with setting  
protocol="org.apache.coyote.http11.Http11NioProtocol"
And then setting <UpgradeProtocol 
className="org.apache.coyote.http2.Http2Protocol" />

That will tell Tomcat to do HTTP2 Correct?

That's the only way to enable h2. Well... you could use Http11Nio2Protocol, too. NIO is the default protocol so you don't even need to add that specifically if you don't want to.

Back to threads.

Each thread (unless you go virtual, but that's not really production-ready IMHO at this point unless you have very strict circumstances where it will work great for you) takes up a bunch of memory, so you can't just set maxThreads=1M. Threads take "time" to start, but it's not really that much. If starting and stopping threads is what is making your application slow, than you have a very high-performance application and environment indeed.

Your question as stated is unanswerable.

You say you are sometimes hitting 500 connections. The default maximum number of connections is 10000 and you are only using 500. That means you aren't being flooded, which is a Good Thing. (BTW: How are you measuring "how many connections" you have? Make sure you are measuring the right thing...

Is your *current* maxThreads set to 500? If so, then your thread pool maximum is set to your high-water mark which seems like it should be fine. If you set your maxThreads to 1000 you won't get any benefit because only 500 requests are ever being sent at once, right?

What else does your application do?

For example, if you have a thread-pool max-threads of 1000 and your application uses an RDBMS for every request but your db connection pool size is more like 10, then many threads waiting on a small number of connections gets you absolutely no benefit. You'd have to make changes elsewhere in your application in order to make use of those extra threads.

Similarly, if you have a big thread pool and a big db connection pool, but your database performs slowly, then having all that power on the application server doesn't really help you.

So anyone trying to answer "how big should be thread pool be" really needs to understand the nature of your application and the other things happening in your environment.

Sometimes the answer is "just add more threads/CPUs/memory" and sometimes the answer is "re-think your application architecture".

-chris

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

Reply via email to