tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Cain <cc...@mhsoftware.com>
Subject RE: multi threading in tomcat
Date Sat, 11 Aug 2001 21:57:34 GMT
Quoting Byrom Robert-LRB005 <Robert.Byrom@invisix.com>:

> This is a point I'm unclear about, ie adding more threads to deal with
> requests, does it really improve overall performance? Why not have a
> single thread waitting on on the HttpConnector to service all requests ,
> the code can be made faster by reducing context switching and in
> addition make it thread safe. I dont believe that Java threading can be
> used to really boost performance, even if you're running the app on a
> multi-processor. I'm not confident that threading in java is useful for
> optimisation rather it just complicates design and makes the application
> more buggy if it isnt crucial.

Multithreading is absolutely vital in a web environment. Otherwise, a server 
could only respond to one person at a time. Not exactly very scalable. As 
others have pointed out, multithreading is common to every web server, 
including all servlet containers as well as stricly Httpd servers.

In practice, this is alot less cumbersome than you would originally think (at 
least in servlets ... I don't do JSP). An application that has decent enough 
separation of business logic and presentation is almost never concerned about 
simultaneous processing of the page itself, so it then just becomes a matter of 
synchronizing access to non-threadsafe external resources. I have developed at 
least a dozen servlet-based applications, and I can honestly count on one hand 
the number of times I've ever had to put in special code for thread-handling or 
synchronization. I've just never bumped into that many real-world cases where 
the multithreaded nature of the container really mattered. Almost _every_ case 
where I thought I might need synchronization boiled down to the fact that what 
I actually needed was separate instances of business objects.

Regards,

Christopher

Mime
View raw message