0

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.

masegaloeh
  • 18,236
  • 10
  • 57
  • 106
Rocherlee
  • 101
  • 1
  • 3
  • No, he doesn't asks for make tomcat faster _in_ _general_, he wants to fasten tomcat in his special configuration. *It is not too broad!* – peterh Jan 28 '15 at 17:13
  • You need to determine where the bottleneck is. You're assuming it's Tomcat not processing the requests fast enough but you don't know that - at least not per the data you provide. It could be many things - how many connections to your MySQL database your Java app has? Is the Java app doing anything else than deserialize and send to database? Based on your metrics it really looks like a connection pool to db being maxed out but not enough data to confirm. – ETL Jan 28 '15 at 17:32
  • I don't think connection pool is the bottleneck. The pool's maxActive is 2000 and MySQL's maxConnections is 4000. When running these tests, the pool connections is about 600 maximum. I checked this by monitoring processlist of MySQL. The problem is both server utilization are < 40% under stress test. How can I make the system utilization higher, will the response time decrease then? – Rocherlee Jan 29 '15 at 01:41
  • Are your REST calls and methods synchronous or asynchronous? If your client instances are having to wait for a response this will add overhead at the server and client. Are your test clients all running on the same machine (if so could the issue be due to the performance of the TCP/IP stack at the client?) How big are the messages you are sending? – Simon W Jan 29 '15 at 22:45
  • I am not sure whether my REST calls are synchronous or asynchronous. If I run NIO connector on Tomcat, isn't it asynchronous? Yes 1000 test clients are from 3 machines. From MySQL's Top command, I notice 21.7% wa. Is this too much? Could it be a bottleneck that needs to be improved? `%Cpu(s): 4.7 us, 3.8 sy, 0.0 ni, 66.6 id, 21.7 wa, 0.0 hi, 3.2 si, 0.0 st` – Rocherlee Jan 30 '15 at 03:33
  • Time and log - there libraries for that - if you time and log the various steps your code takes you might find where it's slowing down. Compare that to Tomcat access log. There is also possibility of time being added by the load tester processing the response, etc. – ETL Jan 30 '15 at 17:04

0 Answers0