There's another reason for this and it has to do with the java.security.SecureRandom 
class.
>From what I can tell, tomcat uses this class to generate a seed value for the
session ID.  The first request for a SecureRandom value (eg. new 
SecureRandom().nextLong()) can take many, many seconds to complete.  After the
first usage however, it returns immediately.  I'm not sure what goes on when
SecureRandom initializes but that seems to be where the slow down occurs.

As a work around, you could create a low priority thread that instantiates a
SecureRandom calls nextLong() then exits, and have this thread get launched by
the init() method of a servlet that gets preloaded.  This solution worked for me.

Regards,
Pete.

Thus spake "pedro salazar" <[EMAIL PROTECTED]> on Fri, 6 Jul 2001 10:01:37 
+0100:

PS> Greetings,
PS> 
PS> why is that my servlet when the first time is invoked, it takes about 30
PS> seconds or more to start when the servlets that came in tomcat are
PS> instantaneous? After the servlet container instantiated and initialized my
PS> servlet, all the following requests are very fast. Is there any advice for
PS> what we should do and don't do in init() method? I just initialize some
PS> properties and a connection pool....
PS> Well is it possible that my servlet container at any time my may shutdown my
PS> servlet to release memory, and another time it will be requested to start
PS> again and take another time too long to start, correct?
PS> 
PS> How can I benchmark the time of instantiation of my servlet and the time of
PS> my init method?
PS> 
PS> System configuration:
PS> -Tomcat 3.2.1
PS> -JDK 1.3
PS> -Linux RedHat 6.2 [kernel 2.2.18]
PS> -PII400Mhz 256Mbytes
PS> 
PS> thanks.
PS> --
PS> <psalazar/>
PS> 
PS> 

Reply via email to