tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From srevi...@g88.net
Subject Re: [Q] Is it safe to create threads in Tomcat web-apps?
Date Mon, 28 Jul 2003 13:39:35 GMT
> From: Tim Funk <funkman () joedog ! org>
> Subject: Re: [Q] Is it safe to create threads in Tomcat web-apps?

> You can create threads all day in tomcat, but here are the importnatn things
> to consider:

> - WHY! Are threads really the correct solution?
> - And last but not least: WHY! Are threads really the correct solution?

I'm getting the impression that you think multiple threads are never
the right answer.  :) That's not necessarily true.

Suppose that your response to a request contains three steps which are
independant of one another; in order to deliver a faster response
time, you'd like to execute them concurrently.

If these three steps are CPU-bound, then the amount of benefit really
depends on the machine; you need multiple CPUs so that the scheduler
can run the different threads on different CPUs.  With a single CPU,
you're not likely to see much benefit.

However, if the three steps are IO-bound, using multiple threads to
run them concurrently can lead to a big improvement.  Most of the time
spent doing IO is spent waiting.  (Particularly if the IO is network
IO, a "sub-request" to a remote site, for example).  If the idle times
occur concurrently instead of serially, you'll certainly do better.

-- 
Steve

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message