0

We have a java application hosted on two different Application Servers with 64GB RAM and 32vCPU each. And HaProxy as a Loadbalancer in front.

With this setup in our VPS servers, we cannot reach 100 concurrent users. The application keeps throwing the below error message even if we have enough free memory(Approximately 40GB RAM).

ERROR org.springframework.boot.context.web.ErrorPageFilter - Forwarding to error page from request [/create-new] due to exception [unable to create new native thread]
java.lang.OutOfMemoryError: unable to create new native thread
    at java.lang.Thread.start0(Native Method) [na:1.8.0_262]
at java.lang.Thread.start(Thread.java:717) [na:1.8.0_262]
at org.codehaus.groovy.runtime.DefaultGroovyStaticMethods.createThread(DefaultGroovyStaticMethods.java:104) ~[groovy-2.4.5.jar:2.4.5]
at org.codehaus.groovy.runtime.DefaultGroovyStaticMethods.start(DefaultGroovyStaticMethods.java:58) ~[groovy-2.4.5.jar:2.4.5]
at sun.reflect.GeneratedMethodAccessor2752.invoke(Unknown Source) ~[na:na]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_262]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_262]
at org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:54) ~[groovy-2.4.5.jar:2.4.5]
at org.codehaus.groovy.runtime.metaclass.NewStaticMetaMethod.invoke(NewStaticMetaMethod.java:53) ~[groovy-2.4.5.jar:2.4.5]
at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite$StaticMetaMethodSiteNoUnwrapNoCoerce.invoke(StaticMetaMethodSite.java:151) ~[groovy-2.4.5.jar:2.4.5]

RAM

App1 # free -m
                              total        used        free      shared  buff/cache   available
                Mem:          65536        21480        44056           2        10341       33715
                Swap:             0           0           0

However, on AWS with the same configuration and setup, the app can handle more than 200 concurrent users.

We are hopeless, any suggestions will be greatly appreciated!

Achu
  • 621
  • 6
  • 13
  • please take a look at OS settings how many native threads can be spawned. Check also https://stackoverflow.com/questions/8203156/java-memory-error-unable-to-create-new-native-thread – smajlo Jul 15 '20 at 12:41
  • 1
    The machine has run out of available memory and cannot create anymore threads. You're going to have to provide some type of in-depth analysis. – Jason Jul 15 '20 at 12:42
  • Sounds like you are NOT passing any -Xmx flag thus JVM is running with default values. So even if your server has lots of memory, JVM is unable to use it. Try [setting Xmx](https://stackoverflow.com/a/1030290/2641683) and [default Xmx](https://stackoverflow.com/a/28273076/2641683) to further understand Xmx and use appropriate value for Xmx. Try setting it to -Xmx40GB , if the application still throws OutOfMemory, you likely have a memory leak in your application. – Avnish Jul 15 '20 at 15:16

0 Answers0