-1

Tomcat is unresponsive and throwing 504 intermittently. But there is not much CPU usage. We suspected it could happen we receive many number of requests and made tomcat unresponsive. We gave 400 as maxThreads in server.xml and the only lead we have is below error in the log.

Maximum number of threads (400) created for connector with address null and port 8090

We use AWS and checked the ELB, It is just 299 requests at that time. So it confusing for us that when we see maximum number of threads in the error and how can ELB shows less that that.

  • 2
    It's really hard to say based on the information provided. Do your logs say anything interesting during the time periods in question? – Katherine Villyard Dec 6 '14 at 20:28
  • Made some edits based on our analysis from the log – Selvakumar P Dec 8 '14 at 12:23
  • Have you tried increasing the maxThreads setting? You're clearly hitting the limit. As to why, you could take some thread dumps to see what the threads are doing at the time. If they're all active then you just need more threads. If some are sitting idle, then you may have connection timeout issues with your LB (i.e. make sure connectionTimeout is set correctly). – Daniel Mikusa Dec 16 '14 at 18:16
2

Such behaviour is often caused by high heap memory usage and/or excessive garbage collection.

When Tomcat gets tight on memory it will start to respond slowly and timeout intermittently. Situation usually deteriorates slowly until it becomes unresponsive.

In such situations you may or may not see high CPU usage. Try to analyse memory usage (JMX may help with this), GC logs and see if that's what causing it.

If that's the case, you likely have memory leak somewhere. So then analyse some more, find it and fix it or keep restarting Tomcat every time it reaches this state.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.