I have the problem that Tomcat 7 is terribly slow on startup. I found this in the log file:
INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [12,367] milliseconds.
Security is important, sure, but not on my development machine. I could perfectly live with a standard fast random number generator. So I don't need this ridiculously slow SecureRandom implementation.
Question is: How can I disable it? Is searched for a solution but only found some deprecated info about a randomClass
attribute which can be set to java.util.Random
. I also found out that this attribute seems to be named secureRandomClass
now in Tomcat 7. I tried to set it to java.util.Random
but this fails because Tomcat 7 casts the object to java.util.SecureRandom (And it's also documented that the specified class must extend java.util.SecureRandom, so it's no longer possible to use java.util.Random instead.)
So how can I get rid of this terribly slow random number generator startup so my development tomcat starts/restarts as fast as possible?
Unfortunately, SecureRandom can be very slow. If it uses /dev/random on Linux, it can block waiting for sufficient entropy to build up.
Connection pooling is a common technique for optimizing database accesses by having a pool of open connections so that requests can take connections from the pool and return connections back to the pool once they are done with their tasks.
If your Tomcat takes longer to start, it may be due to the random number generator that it is using. You might want to consider forcing it to use '/dev/urandom' rather than the default '/dev/random' that Tomcat uses.
According to TomCat Wiki you can use non blocking entropy source:
"There is a way to configure JRE to use a non-blocking entropy source by setting the following system property: -Djava.security.egd=file:/dev/./urandom
"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With