Return-Path: Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: (qmail 53288 invoked from network); 15 Feb 2011 23:01:58 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 15 Feb 2011 23:01:58 -0000 Received: (qmail 31867 invoked by uid 500); 15 Feb 2011 23:01:55 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 31768 invoked by uid 500); 15 Feb 2011 23:01:54 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 31759 invoked by uid 99); 15 Feb 2011 23:01:54 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 15 Feb 2011 23:01:54 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of aw@ice-sa.com designates 212.85.38.228 as permitted sender) Received: from [212.85.38.228] (HELO tor.combios.es) (212.85.38.228) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 15 Feb 2011 23:01:48 +0000 Received: from [192.168.245.129] (p549E0C97.dip0.t-ipconnect.de [84.158.12.151]) by tor.combios.es (Postfix) with ESMTPA id 4BC6E226452 for ; Tue, 15 Feb 2011 23:53:42 +0100 (CET) Message-ID: <4D5B05B3.80501@ice-sa.com> Date: Wed, 16 Feb 2011 00:01:07 +0100 From: =?ISO-8859-1?Q?Andr=E9_Warnier?= Reply-To: Tomcat Users List User-Agent: Thunderbird 2.0.0.23 (Windows/20090812) MIME-Version: 1.0 To: Tomcat Users List Subject: Re: Struts application used as a web service (large number of sessions) References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Denis.Laroche@pwc.ca wrote: > Hello everybody, > > I wrote a Struts application deployed on a Tomcat server that is used as a > web service. What I see is that for every request sent by the client > applications a new session is created; I guess this is because there's no > JSESSIONID cookie sent with the request. Could someone tell me if it's > terribly inefficient for the server to have to create a new session for > every request? I could reduce the session timeout to the minimum, but the > application is also used by interactive users so the session timeout needs > to have a reasonable value. > HttpSession (HttpRequest.)getSession() : Returns the current session associated with this request, or if the request does not have a session, creates one. HttpSession : http://tomcat.apache.org/tomcat-5.5-doc/servletapi/javax/servlet/http/HttpSession.html A session is created when there is a call to getSession(). No call to getSession(), no session. In the big scheme of things, from the above descriptions, I would tend to think that a "session object" is not something trivial, so creating one when you don't need it is probably indeed quite inefficient. (And then the session has to be stored somewhere, which will involve serialization, I/O etc..; and then some background task still has to periodically go clean up these useless sessions). From your description, it seems as if there are two types of usage of the same application : - a usage by real users, which does require a session - a usage as a web service, which does not require a session (because these are one-off calls, probably) I don't know Struts at all, but is it possible to distinguish the two types of usage, and bypass the getSession() call when the application is used as a web service ? Otherwise, would it be possible to set up two instances of your application ? Such as : /webapp1 : used by interactive users /webapp2 : used by web service clients and remove the getSession() call in the one used as a web service ? Now again, inefficiency is a relative concept. If your server is 50% idle anyway, you do not really want to spend a lot of time bringing it to 60% idle. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org