Shariq wrote:
Hi,

My requirement is to measure the request and response bandwidth of a webapp
that's deployed in Tomcat. Basically capture each request and response
bandwidth and store the statistics and do analytics on that data overtime.

Bandwith (http://en.wikipedia.org/wiki/Bandwidth_%28computing%29)
refers to a number of bits/second transmitted over a communications channel.

This is typically something better captured by network equipment (analysers, routers, switches), and it doesn't really make much sense on an application base.

Apart from that, the AccesLogValve can already tell you, on a URL base, how much total time was needed to fulfill the request, and how many bytes (x 8 bits) were sent as a response. (You can probably also get the number of bytes of the request).

But Tomcat is not the only element which intervenes here, and the real bandwidth can also be limited by what the client (and everything in-between) can absorb.

Maybe before we go any further into this, you would like to make more clear what exactly you are trying to measure, and for which purpose ?


We've already written a custom Tomcat Valve to capture plenty of
information regarding requests coming to a webapp. Since both request and
response go through the Valve, I think there should be a way to capture
bandwidth stats in the Valve, but haven't found out how to do it.

One thing we've done previously is to get this information using the Tomcat
RequestInfo.java class. This however doesn't seem like a clean solution.
While digging into the tomcat code, I noticed that we can get the
org.apache.coyote.Request object (that's used in RequestInfo class) in the
Valve as follows;

*org.apache.catalina.connector.request.getCoyoteRequest().getBytesRead();
// 
0org.apache.catalina.connector.request.getCoyoteRequest().getResponse().getContentWritten();
// 0*

But both the above statement always returns 0, which is wrong compared to
the output in RequestInfo class.

Another thing I noticed is that we can get a RequestInfo object within the
valve as follows;

*reqProcessorMX = request.getCoyoteRequest().getRequestProcessor();*

Now if I try to use the *reqProcessorMX* object and call
*getBytesSent()*method it returns the accumulated bytes count and not
the per request
bandwidth. This is what I've managed to gather so far.

Any idea on what could be the issue? Why the coyote.Request is not
returning the correct bandwidth in the Valve? Is there a better way to
capture request/response bandwidth, within a Valve ?!

Many thanks in advance.
Thanks & Regards,
Shariq.



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to