On a linux server with 6 java processes running tc-server with different web-applications, sometimes several servers stop working (almost at the same time) because of this error:
Exception in thread "ajp-bio-9096-Acceptor-0" java.lang.OutOfMemoryError: unable to create new native thread
at java.lang.Thread.start0(Native Method)
at java.lang.Thread.start(Thread.java:714)
at java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:949)
at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1371)
at org.apache.tomcat.util.threads.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:162)
at org.apache.tomcat.util.threads.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:142)
at org.apache.catalina.core.StandardThreadExecutor.execute(StandardThreadExecutor.java:169)
at org.apache.tomcat.util.net.JIoEndpoint.processSocket(JIoEndpoint.java:531)
at org.apache.tomcat.util.net.JIoEndpoint$Acceptor.run(JIoEndpoint.java:234)
at java.lang.Thread.run(Thread.java:745)
This causes the one or more JVM's that are running on 1 machine to stop working.
(we have 6 tc-servers running on the same machine)
It looks like the maximum number of processes on our linux machine is reached.
The max threads on OS-level is about 31389 (ulimit -u)
. But we do not see an excessive number of threads in linux
When I look at the Operating System there are about 1500 threads running
(ps -eLF | wc -l)
When profiling/monitoring the tcserver processes the number of threads per java process is normally between 50 and 150 and under load that can go to 350 because of http-threads, but that will go down and never reaches the max number of threads per process of 1000 (on this machine).
We are using a 64 bit Java 1.7
runtime environment and there is always free memory on the OS.
Today we even got this message 1 minute after server start. The jvm stopped working, but the os process kept running. When looking at the number of threads of this process it was 51.
(ps uH p <pid> | wc -l).
So it looks like a maximum number of threads is reached, but we never see a lot of running threads.