2

I have a Java web application, which runs from JAR, starts embedded Tomcat and is using Spring Boot.

Problem is that it runs very slow when running in KVM virtual guest. The same application in the same JDK (Java(TM) SE Runtime Environment (build 1.8.0_72-b15) Java HotSpot(TM) 64-Bit Server VM (build 25.72-b15, mixed mode) is starting 8 secs on bare metal, but 40 seconds when in virtualized system. Both OSes are Ubuntu 15.10 (kernel 4.2.0-27-generic). And that's not only starting issues, application responds very lazy for every HTTP request.

I've tried to change Java settings about SecureRandom, but nothing has changed.

-Djava.security.egd=file:///dev/urandom

SecureRandom and random entropy in virtual guests: https://security.stackexchange.com/questions/14386/what-do-i-need-to-configure-to-make-sure-my-software-uses-dev-urandom

https://stackoverflow.com/questions/137212/how-to-solve-performance-problem-with-java-securerandom

But it didn't help me. Do you have some other recommends, what to do? Thank you.

My virtual host is a new server with plenty of RAM, SSDs.. so I'm quite sure there is no hardware issue. I'm also running other KVM virtual guests and no problem at all. Only with slow Java application.

  • Java 5 and later -Djava.security.egd=file:/dev/./urandom, for /dev/random see serverfault.com/questions/437798/… – Federico Sierra Feb 5 '16 at 4:12
  • I'm starting app with java -Djava.security.egd=file:/dev/./urandom -jar web.war, but startup time is the same. I'm not sure if the problem is related to bad random entropy. – Xdg Feb 5 '16 at 7:13
  • When I run it on 2,00 GHz CPU, it runs about two times slower than on 3,50 GHz CPU - both running in LXC container. But I don't want to believe that 2,00 GHz is so slow that my Java webapp respond in about 100 ms (minimum). On faster CPU it's about 55 ms. – Xdg Sep 3 '17 at 7:43
3

If your application is using SecureRandom, you might need to install a random entropy generator, like haveged so that there is enough entropy for the initial seed.

VMs have a problem gathering entropy.

Virtual servers are running in an emulated environment, with very little access to “real” hardware. The random data that conventional computers get from their hardware doesn’t happen with emulated virtual hardware, so the prime source of entropy just isn’t present.

Source

This would at least be expected to improve performance the first time it is used.

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.