You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Tony Anecito <ad...@yahoo.com> on 2008/11/25 18:48:21 UTC

SingleThreadModel for servlets

Hello All,

I am wondering with the advances in hardware and memory and using servlet pooling if using SingleThreadModel is better for performance than multiple threads per servlet.
Reason I ask is if you have a slow service using the multithreaded servlet it might be a bad idea especially if there is synchronous methods used anywhere in the code for a multithreaded servlet.

Regards,
-Tony


      

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


RE: SingleThreadModel for servlets

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Tony Anecito [mailto:adanecito@yahoo.com]
> Subject: RE: SingleThreadModel for servlets
>
> The question I wanted answered was in general if current real
> life experience still holds true that the mutli-threaded
> single servlet model is still faster than one servlet per
> thread where the servlet is pooled.

For a properly written webapp, I doubt that you'll be able to measure much difference in CPU performance, other than the increased likelihood of operand cache misses when you have multiple active Servlet objects rather than just one.  There would be some increase in Java heap (and therefore RAM) usage as well, but given enough real memory that's not likely to be an issue.

 - 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 start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: SingleThreadModel for servlets

Posted by Tony Anecito <ad...@yahoo.com>.
Hi Charles,

Thanks for the prompt answer. I was only giving an example. The question I wanted answered was in general if current real life experience still holds true that the mutli-threaded single servlet model is still faster than one servlet per thread where the servlet is pooled.

Thanks,
-Tony


--- On Tue, 11/25/08, Caldarale, Charles R <Ch...@unisys.com> wrote:

> From: Caldarale, Charles R <Ch...@unisys.com>
> Subject: RE: SingleThreadModel for servlets
> To: "Tomcat Users List" <us...@tomcat.apache.org>
> Date: Tuesday, November 25, 2008, 10:58 AM
> > From: Tony Anecito [mailto:adanecito@yahoo.com]
> > Subject: SingleThreadModel for servlets
> >
> > Reason I ask is if you have a slow service using the
> > multithreaded servlet it might be a bad idea
> especially
> > if there is synchronous methods used anywhere in the
> code
> > for a multithreaded servlet.
> 
> Synchronization should be there for a reason, not just
> because the programmer thought it looked pretty.  If
> something needs to be protected, that requirement will exist
> regardless of whether there are one or many copies of a
> particular Servlet object.  If the programmer has been
> sloppy and is using synchronization on instance variables
> for cases where local variables should have been used,
> you've got a badly written servlet that should be
> corrected.
> 
>  - 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 start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail:
> users-help@tomcat.apache.org


      

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


RE: SingleThreadModel for servlets

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Tony Anecito [mailto:adanecito@yahoo.com]
> Subject: SingleThreadModel for servlets
>
> Reason I ask is if you have a slow service using the
> multithreaded servlet it might be a bad idea especially
> if there is synchronous methods used anywhere in the code
> for a multithreaded servlet.

Synchronization should be there for a reason, not just because the programmer thought it looked pretty.  If something needs to be protected, that requirement will exist regardless of whether there are one or many copies of a particular Servlet object.  If the programmer has been sloppy and is using synchronization on instance variables for cases where local variables should have been used, you've got a badly written servlet that should be corrected.

 - 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 start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org