I presume from the questions that you're talking about Tomcat 4, so I will
answer on that basis.
On Wed, 1 Aug 2001, Grobe, Gary wrote:
>
> After reading the Tomcat architecure docs, I have a question.
>
> Is there anyway to call the invoke method of a container from the webserver
> whenever needed. i.e. If I wanted to get the time it takes for the web
> server to process a request, could the server engine be invoke()'d to
> startTime and when the webserver finished handling the request, is there
> some way it could be invoked again to stopTime so that I'd know how long it
> took?
Depending on *exactly* what you want to measure, this can be easy or
hard. Let's assume Tomcat stand-alone first.
The easiest thing to do would be to write a simple Valve that did these
timings, and stick it first in the Valves nested inside the Engine. This
would track all of the execution time within the core part of Catalina,
but would not include the time used to read and parse the HTTP request, or
the time used to actually send the response back out the socket.
Aside: you can do this kind of thing in a portable
manner by writing a Filter instead. This would measure
the time within your application only, but it would run
on any servlet 2.3 container. There is just such a filter
in the "examples" web app included with Tomcat.
If you really want to time Apache+Tomcat, then you need to start the timer
when Apache starts working on the request, and stop the timer after Apache
has completed the response. That means you'll need to modify Apache code,
not just Tomcat.
>
> I know that in order for the servlet to do this it must handle the request
> and I could get the times from the response and then the request, but I'm
> looking to see if I can *monitor* (if that's the right word) the web servers
> performance or it's requests in some way. Maybe someway to make callbacks to
> the webserver?
>
I'm not sure how callbacks would help you ... don't you really want Apache
to report the total time required to its log files? You might want to
investigate whether there are any Apache plug-in modules that do this kind
of thing.
> My reason for wanting apache to handle the requests is because of sites that
> have very large connection loads that our clients/or Tomcat will not accept
> performace wise. If this part doesn't make sense, please ignore as their are
> other reasons also.
>
>
If I were you, I'd consider primarily focusing on the time spent *within*
your app rather than the total time. However, as I'm sure you know, the
time required to do a particular request will be very much affected by
what else is going on at that particular moment -- one of the eternal
challenges of benchmarking :-).
Craig