You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by psalazar <pe...@ptinovacao.pt> on 2001/07/17 23:04:40 UTC

getSession(true) takes more than 20 seconds????

Greetings,

I have a servlet that when a request arrives, it makes a profile using 
the header "User-Agent" (which contains the type of the client). But, 
this process was taking too long and I thought it was my 
ProfileFinder.getProfile() method! But, when I made some logs (I put it 
below with the source), I saw that the time is "wasted" in the process 
of retrieving of session object from request!!!

How can it be?? 20 seconds to get (create) a session object?? The first 
time I create a session object it takes 20 seconds!!

I really, really appreciate any help on this....

My system:
-linux redhat 6.2 (kernel 2.2.18)
-tomcat3.2.1
-jdk1.3.0
-PII400 with 256MB

thanks,
Pedro Salazar (my stuff is below)

---------------SOURCE------------------------

long t0=System.currentTimeMillis();

HttpSession sesssion=req.getSession(true);

long t1=System.currentTimeMillis();
getServletContext()log("time:"+(t1-t0) );

Profile p=(Profile)session.getAttribute("profile");

long t2=System.currentTimeMillis();
getServletContext().log("time:"+(t2-t1) );

if(p==null){
     String value = req.getHeader("User-Agent");

         long t3=System.currentTimeMillis();
         getServletContext().log("time:"+(t3-t2) );

         p=new Profile(ProfileFinder.getProfile(value));

         long t4=System.currentTimeMillis();
         getServletContext().log("time:"+(t4-t3) );

     session.setAttribute("profile",p);
}

---------OUTPUT---------------------------
2001-07-17 09:29:49 - path="/sad" :servletInicio: time:21338
2001-07-17 09:29:49 - path="/sad" :servletInicio: time:1
2001-07-17 09:29:49 - path="/sad" :servletInicio: time:1
2001-07-17 09:29:49 - path="/sad" :servletInicio: time:146
-------------------------------------------




Re: getSession(true) takes more than 20 seconds????

Posted by pedro salazar <pe...@ptinovacao.pt>.
Well, I shouldn't reply just for thanks, but, the relief you gave me here
compels me to do it!, since I'm trying to exhibit (and prove) the Java
technology (and other good partnerships as linux) to some people here...
Thank you very much! :-)

pedro salazar

[to all: forgive me this useless and somehow kind of spam in this "heavy"
distribution list]

----- Original Message -----
From: "Endre Stølsvik" <En...@Stolsvik.com>
To: <to...@jakarta.apache.org>
Sent: Wednesday, July 18, 2001 8:30 AM
Subject: Re: getSession(true) takes more than 20 seconds????


> On Tue, 17 Jul 2001, psalazar wrote:
>
> | How can it be?? 20 seconds to get (create) a session object?? The first
> | time I create a session object it takes 20 seconds!!
>
> bcoz it uses SecureRandom. It only happens the first time (first
> getSession()), when the secure stuff initializes. God knows what it's
> doing, but the next calls to random goes much faster, just try to log in
> another user, and you'll see.
>
> You can, for development sake, use another random class, you set this in
> tomcat-conf.xml thingy.
>
> |
> | I really, really appreciate any help on this....
>
> Happy? ;)
>
>
> --
> Mvh,
> Endre



Re: getSession(true) takes more than 20 seconds????

Posted by Endre Stølsvik <En...@Stolsvik.com>.
On Tue, 17 Jul 2001, psalazar wrote:

| How can it be?? 20 seconds to get (create) a session object?? The first
| time I create a session object it takes 20 seconds!!

bcoz it uses SecureRandom. It only happens the first time (first
getSession()), when the secure stuff initializes. God knows what it's
doing, but the next calls to random goes much faster, just try to log in
another user, and you'll see.

You can, for development sake, use another random class, you set this in
tomcat-conf.xml thingy.

|
| I really, really appreciate any help on this....

Happy? ;)


-- 
Mvh,
Endre