Search code examples
javatomcat7

Slow startup on Tomcat 7.0.57 because of SecureRandom


I'm using Tomcat 7.0.57 on CentOS 6.6 32 bit and openJDK7. When I start 14 different instances of Tomcat on my server(production environment), many of them take too much time to start.

This is part of the startup log, which tells me where is taking all the time

Jan 28, 2015 2:49:41 PM org.apache.catalina.util.SessionIdGenerator createSecureRandom
INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [199,620] milliseconds.

What's the best practice/solution for this problem?

Thanks!


Solution

  • The secure random calls may be blocking as there is not enough entropy to feed them in /dev/random.

    If you have the line

    securerandom.source=file:/dev/random
    

    in /jre/lib/security/java.security, changing this to urandom may improve things (although this is probably already the default).

    Alternatively there are some suggestions on how to feed the pool here

    https://security.stackexchange.com/questions/89/feeding-dev-random-entropy-pool