Mark and Jerry,
On 5/1/24 04:00, Mark Thomas wrote:
On 30/04/2024 21:24, Jerry Malcolm wrote:
I'm trying to optimize my instance, CPU, tuning, and size requirements
for Tomcat. It's easy to see CPU usage. But this TC instance is
running a lot of microservices that are often in and out fairly
quickly. So there can be a huge number of requests coming in. I'm
not sure that CPU starving is my biggest concern. I'm more interested
is getting an understanding of TC front end bottlenecks and also JDBC
data connection bottlenecks. So I need a bit of education. Am I
correct that maxThreads on the connector throttles the number of
requests that can come in at one time?
Not quite.
maxThreads is the maximum number of concurrent requests that Tomcat can
process. This excludes:
- connections in keep-alive
- requests that have entered async mode and have exited the original
container thread
This includes:
- multiple requests received on a single HTTP/2 connection
The maximum number of connections is controlled by maxConnections.
And connectionTimeout is the time to wait to get in the door if
threads are maxed out before giving up and failing, correct?
No. It is the maximum time Tomcat will wait from the point the
connection is accepted to reading the first byte of data.
I'd really like to track total threads in use and then track wait time
if total threads are maxed out. Likewise, with database connections.
You can track the status of the thread pool but wait time isn't
available as Tomcat has no visibility into the accept queue (see
acceptCount). Your OS might provide some stats here.
I'd like to monitor the jdbc connection pool as well and see when
and where the code is having to wait for a db connection and how long
the average wait is. I assume there are jms hooks to monitor this?
Correct. You probably want the stats from the o.a.t.u.dbcp.pool2.impl
package.
But I don't want to reinvent the wheel. Are there tools out there to
assist with this already? Thx
Generally, I start with a profiler when looking at questions like this.
I use YourKit because they given me a free copy to use for Tomcat
development but there are lots of different profilers available.
There are some good places to look in this monitoring presentation from
ApacheCon:
https://tomcat.apache.org/presentations.html#latest-monitoring-with-jmx
It's easy to set up periodic monitoring of those various values and then
use your tool of choice to graph, investigate, etc. how those values
change over time and possibly correlate.
Tomcat is unlikely to be the bottleneck in any of these cases. You are
likely to find that your database is the limiting factor. On the other
hand, if your database is beefy but your JDBC connection pool is limited
to 10 connections and you have a lot of concurrency, then your database
is probably sitting idle while your application server has lots of
waiting requests.
Just be careful about ramping things up on the database side. Not all
database queries are equal ;)
-chris
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org