I have Tomcat 8 and MySQL 5.6 running in 2 Azure virtual machines (8 cores and 28 GB RAM). My web application provides a REST API to insert several data fields into DB. The application uses a common dbcp connection pool to talk to the DB.
I use httpclient to generate requests to the application. Each httpclient creates 1 request per second.
For 1 client, the response time is about 170ms.
For 500 clients, the average response time increases to nearly 800 ms. Throughput is about 370 TPS.
For 1000 clients, the average response time increases to nearly 1200 ms. Throughput is still the same of 370 TPS.
During the tests, CPU and RAM utilization on both server are under 40%, which I think is inefficient. HTTP Error rate is very low.
My Tomcat config (using NIO protocol)
<connector connectiontimeout="20000"
maxThreads="600"
port="8080"
protocol="org.apache.coyote.http11.Http11NioProtocol"
redirectport="8443" />
When I increase or decrease maxThreads
, the response time goes higher.
How can I make Tomcat process requests faster? Given the server specs, I expect Tomcat's average response time for 500/1000 concurrent clients is under 500ms/1000ms.