Re: Struts application used as a web service (large number of sessions)
Ok thanks, your explanations were very useful. I'll do what you suggested, i.e. not create a session for the Struts actions matching the web service clients. -- DL André Warnier a...@ice-sa.com 2011-02-15 06:02 PM Please respond to Tomcat Users List users@tomcat.apache.org To Tomcat Users List users@tomcat.apache.org cc Subject Re: Struts application used as a web service (large number of sessions) denis.laro...@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-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Struts application used as a web service (large number of sessions)
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. Thanks in advance. -- D. Laroche Pratt Whitney Canada --- Ce courriel contient des renseignements confidentiels de PWC et le fait de le recevoir ne constitue pas une autorisation d'en utiliser ou divulguer le contenu. This email contains confidential information of PWC and its receipt does not constitute an authorization to use or disclose its contents. ---
RE: Struts application used as a web service (large number of sessions)
From: denis.laro...@pwc.ca [mailto:denis.laro...@pwc.ca] Subject: Struts application used as a web service (large number of sessions) I wrote a Struts application deployed on a Tomcat server that is used as a web service. Exact Tomcat version? I guess this is because there's no JSESSIONID cookie sent with the request. So your clients are violating the spec by ignoring cookies? If so, you can set cookies=false in the Context element for your webapp, _and_ always use URL rewriting for your responses. - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Struts application used as a web service (large number of sessions)
denis.laro...@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-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org