You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Nick Betteridge <n....@syntactics.com> on 2000/09/21 15:00:17 UTC

Virtual hosts, Catalina and resources

I'm in the middle of trying to set up Catalina using the Embedded class
to create virtual hosts (straight forward) and then monitor each virtual
host resource.

What is relatively easy is the resource allocation of the connection
thread for the HttpSession/HttpConnection thread - accessed via JNI.

The physical disk resources of each virtual host - really a collection
of war directories - is also straight forward.

The area where I'm hung up is the resource measurement of the virtual
host footprints that are in the JVM.

I'm in the middle of setting up each StandardHost as a thread but I'm
not too sure if I'm wandering down the wrong path.

Any input or suggestions from anybody?

Thanks
Nick

Re: Virtual hosts, Catalina and resources

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
Hi Nick, see below.

Nick Betteridge wrote:

> I'm in the middle of trying to set up Catalina using the Embedded class
> to create virtual hosts (straight forward) and then monitor each virtual
> host resource.
>
> What is relatively easy is the resource allocation of the connection
> thread for the HttpSession/HttpConnection thread - accessed via JNI.
>
> The physical disk resources of each virtual host - really a collection
> of war directories - is also straight forward.
>
> The area where I'm hung up is the resource measurement of the virtual
> host footprints that are in the JVM.
>
> I'm in the middle of setting up each StandardHost as a thread but I'm
> not too sure if I'm wandering down the wrong path.
>

In the current implementation, none of the Container components (Engine,
Host, Context, Wrapper) create their own threads at all, except for
background threads started to manage automatic reloading (if enabled) or
session expiration.  They rely on the Connector implementation to supply the
running thread on which each individual request is executed.  And, because
the Connector implementations recycle threads, a given thread can be used by
different virtual hosts at different times.

So, while no requests are active, the StandardHost object itself occupies
zero CPU time.  The only CPU time occupied by any webapps running on that
host are the background ticker tasks for reloading and session expiration.

It's memory footprint is problematic to calculate, but would be the sum of
the space occupied by the StandardHost object itself, all subordinate
objects (Contexts and their webapps), and so on.  But how do you ask the JVM
how much memory any given Java object is occupying so that you can add this
up?

>
> Any input or suggestions from anybody?
>

One thing you might think about is adding a Valve at the host level that
tracks the amount of time spent handling a particular request, and counting
it towards the resource usage of that host.  The fact that your Valve
actually received the request means that it belongs to this host, and this
approach also deals with multiple simultaneous requests gracefully (although
obviously overlapping requests will be counting the same wall clock time).

>
> Thanks
> Nick

Craig

====================
See you at ApacheCon Europe <http://www.apachecon.com>!
Session VS01 (23-Oct 13h00-17h00):  Sun Technical Briefing
Session T06  (24-Oct 14h00-15h00):  Migrating Apache JServ
                                    Applications to Tomcat