You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Lukas Bradley <lu...@somnia.com> on 2003/09/05 21:51:53 UTC

Servlet/JSP Lifecycle and Performance

All,

Where can I get a description of how Tomcat handles a Servlet lifecycle from
init() to removal from memory?  I'm interested in how long a Servlet is held
in memory, and how long it remains inactive before it is removed from the
Servlet pool.

Also, are there performance statistics of the maximum number of Servlets
used versus number of simultaneous requests?  In other words, if there are
1000 simultaneous requests, what is the performance sacrifice for having
2000 active servlets versus 200?  Assume memory and processing power is
ample.

Thanks for any and all information or comments.

Lukas




Re: Multiple Tomcat instances for virtual hosts

Posted by "Dhruva B. Reddy" <sl...@yahoo.com>.
This doesn't really answer your question, but we've found Tomcat to be
quite robust.  You may also want to find out (if you don't already
know) what's bringing the server down.

-d

--- Thomas Eichberger <th...@gmx.net> wrote:
> Hi,
> 
> I have Apache 1.3 and Tomcat 4.1.8 on a Red Hat 9 machine.
> 
> Apache serves several virutal hosts. We have one Tomcat instance
> running 
> with several web contexts, one context for each virtual host.
> 
> Now I would like to change this to have one Tomcat instance for each 
> virtual host (this is necessary because Tomcat sometimes crashes, and
> I 
> don't want all virtual hosts to be down then).
> 
> I read a book about Tomcat and searched the Web, but could not find
> out how 
> to do this. What I assume is:
> 
> 
> In Apache's httpd.conf I have something (after the import of mod_jk):
> 
> NameVirtualHost 200.200.200.200 (or whatever)
> 
> <VirtualHost 200.200.200.200>
> ServerName www.xxx.com
> DocumentRoot /tomcat1/webapps/xxx
> JkMount /servlet/* worker1
> JkMount /*.jsp worker1
> JkMount /*.do worker1
> </VirtualHost>
> 
> <VirtualHost 200.200.200.200>
> ServerName www.yyy.com
> DocumentRoot /tomcat2/webapps/yyy
> JkMount /servlet/* worker2
> JkMount /*.jsp worker2
> JkMount /*.do worker2
> </VirtualHost>
> 
> 
> Then I will install Tomcat two times, in /tomcat1 and /tomcat2.
> 
> The server.xml of each Tomcat contains different ports (for shutdown
> and 
> for the connector for ajp13).
> 
> 
> The workers.properties should look like:
> 
> worker.list=worker1,worker2
> ...
> worker.worker1.port=8009
> worker.worker1.host=localhost
> worker.worker1.type=ajp13
> ...
> worker.worker1.port=8010
> worker.worker1.host=localhost
> worker.worker1.type=ajp13
> 
> 
> Is this all correct? Should that work?
> 
> Thomas
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

Re: Multiple Tomcat instances for virtual hosts

Posted by Sai Sivanesan <sa...@opensource.dibacanada.com>.
I really like the idea of setting up multiple instances of Tomcat per virtual
site - i have 2 questions:

1)  How does it affect memory usage, i.e.  if we are on a server with X
ammount of ram and there are 20 sites, does each site end up needing a minimum
of ~21 MB RAM for tomcat so we have a basic need of 420MB ram being used just
to keep tomcat up / site?

2)  If one site gets busier then will it slow down the other sites more so
than using mod_jk / mod_webapp?

sai

On Sat, 06 Sep 2003 21:05:38 -0400, Bob Langford wrote
> Your plan should work pretty well.  I do something similar myself. 
>  The major difference is that I use one installation of Tomcat for 
> all the sites. I have a script to start tomcat for each site, that 
> points CATALINA_HOME to the shared Tomcat binaries, and 
> CATALINA_BASE to the conf/, logs/, temp/, work/, and webapps/ 
> directories for the site:
> 
> file /home/site1/tomcat/catalina:
>    #!/bin/sh
>    CATALINA_BASE = "/home/site1/tomcat"
>    CATALINA_HOME = "/usr/share/tomcat4"      (or whatever)
>    CATALINA_OPTS = "-server"                  (maybe others)
>    export CATALINA_BASE CATALINA_HOME CATALINA_OPTS
>    $CATALINA_BASE/bin/catalina.sh  $*
> 
> I can do   ./catalina start,     ./catalina stop,    etc to control each
> site.  It works pretty well, especially if you're developing one 
> site while others are in production.
> 
> Two things to watch for:
> 1)  You are correct that you have to use different ports for each 
> server.xml file.
> I declared that site one could have ports between 8100-8199, site 2 
> between 8200-8299, etc.  Each project can use whatever they want in 
> their range.
> 
> 2)  Since these Tomcat instances listen on ports above 1024, they 
> don't need to be started by the "root" user.  If they did, I'd be 
> very wary of putting the server.xml file (and other config files and 
> scripts) where the user could modify them.  Also, your system boot 
> procedures need to take some steps to start them using the correct username.
> 
> 3)  I use Apache as a front end for all these Tomcat instances,
>  using a proxy instead of JK or JK2.  In each virtual host, there's 
> something like this:     ProxyPass         /examples/    
http://localhost:8181/examples/
>      ProxyPassReverse  /examples/     http://localhost:8181/examples/
> There are two nice things about this:  Apache logs everything, 
> making it easier to do usage reports.  And, all the connections to 
> Tomcat come from Apache and localhost, so I can block outside 
> connections to all ports except the ones Apache listens to.  However,
>  it's still possible for user A to change his server.xml file to 
> listen to a port that's being sent traffic for user B.  For my 
> purposes, that's not an issue; for others, it may be.
> 
> Good luck!
>      ...Bob Langford...
> 
> At 02:12 PM 9/6/2003, you wrote:
> >Hi,
> >
> >I have Apache 1.3 and Tomcat 4.1.8 on a Red Hat 9 machine.
> >
> >Apache serves several virutal hosts. We have one Tomcat instance running 
> >with several web contexts, one context for each virtual host.
> >
> >Now I would like to change this to have one Tomcat instance for each 
> >virtual host (this is necessary because Tomcat sometimes crashes, and I 
> >don't want all virtual hosts to be down then).
> >
> >I read a book about Tomcat and searched the Web, but could not find out 
> >how to do this. What I assume is:
> >
> >
> >In Apache's httpd.conf I have something (after the import of mod_jk):
> >
> >NameVirtualHost 200.200.200.200 (or whatever)
> >
> ><VirtualHost 200.200.200.200>
> >ServerName www.xxx.com
> >DocumentRoot /tomcat1/webapps/xxx
> >JkMount /servlet/* worker1
> >JkMount /*.jsp worker1
> >JkMount /*.do worker1
> ></VirtualHost>
> >
> ><VirtualHost 200.200.200.200>
> >ServerName www.yyy.com
> >DocumentRoot /tomcat2/webapps/yyy
> >JkMount /servlet/* worker2
> >JkMount /*.jsp worker2
> >JkMount /*.do worker2
> ></VirtualHost>
> >
> >
> >Then I will install Tomcat two times, in /tomcat1 and /tomcat2.
> >
> >The server.xml of each Tomcat contains different ports (for shutdown and 
> >for the connector for ajp13).
> >
> >
> >The workers.properties should look like:
> >
> >worker.list=worker1,worker2
> >...
> >worker.worker1.port=8009
> >worker.worker1.host=localhost
> >worker.worker1.type=ajp13
> >...
> >worker.worker1.port=8010
> >worker.worker1.host=localhost
> >worker.worker1.type=ajp13
> >
> >
> >Is this all correct? Should that work?
> >
> >Thomas
> >
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 
> --
> Bob Langford
> Silicon Masters Consulting, Inc.    8207 Stone River Court, Richmond,
>  VA  23235 phone:  804-674-1253      fax:  804-745-6650 
> http://www.silicon-masters.com/  
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org



--
Open WebMail Project (http://openwebmail.org)


Re: Multiple Tomcat instances for virtual hosts

Posted by Bob Langford <la...@silicon-masters.com>.
Your plan should work pretty well.  I do something similar myself.  The major
difference is that I use one installation of Tomcat for all the sites.
I have a script to start tomcat for each site, that points CATALINA_HOME to 
the
shared Tomcat binaries, and CATALINA_BASE to the conf/, logs/, temp/, 
work/, and
webapps/ directories for the site:

file /home/site1/tomcat/catalina:
   #!/bin/sh
   CATALINA_BASE = "/home/site1/tomcat"
   CATALINA_HOME = "/usr/share/tomcat4"      (or whatever)
   CATALINA_OPTS = "-server"                  (maybe others)
   export CATALINA_BASE CATALINA_HOME CATALINA_OPTS
   $CATALINA_BASE/bin/catalina.sh  $*

I can do   ./catalina start,     ./catalina stop,    etc to control each
site.  It works pretty well, especially if you're developing one site while
others are in production.

Two things to watch for:
1)  You are correct that you have to use different ports for each 
server.xml file.
I declared that site one could have ports between 8100-8199, site 2 between 
8200-8299,
etc.  Each project can use whatever they want in their range.

2)  Since these Tomcat instances listen on ports above 1024, they don't 
need to
be started by the "root" user.  If they did, I'd be very wary of putting the
server.xml file (and other config files and scripts) where the user could
modify them.  Also, your system boot procedures need to take some steps to
start them using the correct username.

3)  I use Apache as a front end for all these Tomcat instances, using a proxy
instead of JK or JK2.  In each virtual host, there's something like this:
     ProxyPass         /examples/     http://localhost:8181/examples/
     ProxyPassReverse  /examples/     http://localhost:8181/examples/
There are two nice things about this:  Apache logs everything, making it
easier to do usage reports.  And, all the connections to Tomcat come
from Apache and localhost, so I can block outside connections to all
ports except the ones Apache listens to.  However, it's still possible for
user A to change his server.xml file to listen to a port that's being sent
traffic for user B.  For my purposes, that's not an issue; for others, it
may be.

Good luck!
     ...Bob Langford...

At 02:12 PM 9/6/2003, you wrote:
>Hi,
>
>I have Apache 1.3 and Tomcat 4.1.8 on a Red Hat 9 machine.
>
>Apache serves several virutal hosts. We have one Tomcat instance running 
>with several web contexts, one context for each virtual host.
>
>Now I would like to change this to have one Tomcat instance for each 
>virtual host (this is necessary because Tomcat sometimes crashes, and I 
>don't want all virtual hosts to be down then).
>
>I read a book about Tomcat and searched the Web, but could not find out 
>how to do this. What I assume is:
>
>
>In Apache's httpd.conf I have something (after the import of mod_jk):
>
>NameVirtualHost 200.200.200.200 (or whatever)
>
><VirtualHost 200.200.200.200>
>ServerName www.xxx.com
>DocumentRoot /tomcat1/webapps/xxx
>JkMount /servlet/* worker1
>JkMount /*.jsp worker1
>JkMount /*.do worker1
></VirtualHost>
>
><VirtualHost 200.200.200.200>
>ServerName www.yyy.com
>DocumentRoot /tomcat2/webapps/yyy
>JkMount /servlet/* worker2
>JkMount /*.jsp worker2
>JkMount /*.do worker2
></VirtualHost>
>
>
>Then I will install Tomcat two times, in /tomcat1 and /tomcat2.
>
>The server.xml of each Tomcat contains different ports (for shutdown and 
>for the connector for ajp13).
>
>
>The workers.properties should look like:
>
>worker.list=worker1,worker2
>...
>worker.worker1.port=8009
>worker.worker1.host=localhost
>worker.worker1.type=ajp13
>...
>worker.worker1.port=8010
>worker.worker1.host=localhost
>worker.worker1.type=ajp13
>
>
>Is this all correct? Should that work?
>
>Thomas
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org

--
Bob Langford
Silicon Masters Consulting, Inc.    8207 Stone River Court, Richmond, VA  23235
phone:  804-674-1253      fax:  804-745-6650 
http://www.silicon-masters.com/  



Multiple Tomcat instances for virtual hosts

Posted by Thomas Eichberger <th...@gmx.net>.
Hi,

I have Apache 1.3 and Tomcat 4.1.8 on a Red Hat 9 machine.

Apache serves several virutal hosts. We have one Tomcat instance running 
with several web contexts, one context for each virtual host.

Now I would like to change this to have one Tomcat instance for each 
virtual host (this is necessary because Tomcat sometimes crashes, and I 
don't want all virtual hosts to be down then).

I read a book about Tomcat and searched the Web, but could not find out how 
to do this. What I assume is:


In Apache's httpd.conf I have something (after the import of mod_jk):

NameVirtualHost 200.200.200.200 (or whatever)

<VirtualHost 200.200.200.200>
ServerName www.xxx.com
DocumentRoot /tomcat1/webapps/xxx
JkMount /servlet/* worker1
JkMount /*.jsp worker1
JkMount /*.do worker1
</VirtualHost>

<VirtualHost 200.200.200.200>
ServerName www.yyy.com
DocumentRoot /tomcat2/webapps/yyy
JkMount /servlet/* worker2
JkMount /*.jsp worker2
JkMount /*.do worker2
</VirtualHost>


Then I will install Tomcat two times, in /tomcat1 and /tomcat2.

The server.xml of each Tomcat contains different ports (for shutdown and 
for the connector for ajp13).


The workers.properties should look like:

worker.list=worker1,worker2
...
worker.worker1.port=8009
worker.worker1.host=localhost
worker.worker1.type=ajp13
...
worker.worker1.port=8010
worker.worker1.host=localhost
worker.worker1.type=ajp13


Is this all correct? Should that work?

Thomas



Re: Servlet/JSP Lifecycle and Performance

Posted by Bill Barker <wb...@wilshire.com>.
"Lukas Bradley" <lu...@somnia.com> wrote in message
news:bjgdmh$7fo$1@localhost.localdomain...
> > AFAIK, no such benchmarks have been made.
> > Once tomcat loads a servlet, it is loaded. Tomcat currently does not
> unload
> > servlets due to lack of use.
>
> Is this the case with Tomcat 5?

Currently, yes.

>
> Lukas




Re: Servlet/JSP Lifecycle and Performance

Posted by Lukas Bradley <lu...@somnia.com>.
> AFAIK, no such benchmarks have been made.
> Once tomcat loads a servlet, it is loaded. Tomcat currently does not
unload
> servlets due to lack of use.

Is this the case with Tomcat 5?

Lukas




Re: Servlet/JSP Lifecycle and Performance

Posted by Tim Funk <fu...@joedog.org>.
AFAIK, no such benchmarks have been made.

Once tomcat loads a servlet, it is loaded. Tomcat currently does not unload 
servlets due to lack of use.


-Tim

Lukas Bradley wrote:

> All,
> 
> Where can I get a description of how Tomcat handles a Servlet lifecycle from
> init() to removal from memory?  I'm interested in how long a Servlet is held
> in memory, and how long it remains inactive before it is removed from the
> Servlet pool.
> 
> Also, are there performance statistics of the maximum number of Servlets
> used versus number of simultaneous requests?  In other words, if there are
> 1000 simultaneous requests, what is the performance sacrifice for having
> 2000 active servlets versus 200?  Assume memory and processing power is
> ample.
> 
> Thanks for any and all information or comments.
> 
> Lukas
>