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.
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.
Source
This would at least be expected to improve performance the first time it is used.