Mohamed Mohamedin wrote:
I am facing a problem with tomcat which make it start very slowly. I found
while searching that Tomcat reading from /dev/random to get random numbers
may be the cause. So I am asking How to prevent that? Or if there is another
cause please tell me.

Is this just Tomcat, without any applications installed yet -- or does it
already have webapps or other add-on code installed? I'd like to know, because
this might help in classifying the problem as either concerning Tomcat or one
of the installed applications.

Also, when Tomcat is hanging, could you take a thread dump on what is running,
to show the call stack for the thread waiting for random numbers. This would
be a great help in pinpointing the actual piece of code responsible for the 
delay.

As for actual help, it looks like Java on Linux uses /dev/random as source of
randomness when a piece of code requires "SecureRandom" numbers. /dev/random,
by definition, will block until there is enough entropy (randomness) available
to satisfy the application requirements -- and on a lightly used machines this
may take quite a time.

The solutions are to either change the application to use regular 
java.util.Random
instead of java.security.SecureRandom -- or to degrade the random source 
provided
by Linux from /dev/random to /dev/urandom. This can be done either through
changing the java.security file provided with the Sun Java distribution
(documentation is within the file), or -which I would consider a better 
practice-
by setting the "less random" random source just for the JVM running Tomcat with
-Djava.security.egd=file:/dev/urandom command line parameter.

Hope this helps -- but please don't jump right to changing the random source;
try to pinpoint first where (in Tomcat code or application code) the access to
/dev/random happens.

--
..Juha

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to