tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Justin Ruthenbeck <just...@nextengine.com>
Subject Re: How can I display number of requests over the past n seconds?
Date Mon, 02 Aug 2004 18:52:20 GMT

More academic exercise than recommendation, but...

Write your own implementation of a Map/HashMap
     specific to java.util.Date objects.
Identify your smallest time increment (5 seconds in your email).
Identify largest time increment (60 seconds)
Create (60/5)+1 buckets for your hash function

Write your hash function such that each date object -- representing one 
request each -- gets placed in the right bucket.  If the bucket contains 
"aged" dates, which you should know by simple counting (not comparison), 
empty it before placing a new one in.

To display results, simply add up the content size of the appropriate 
buckets and return.

This implementation is more lightweight than others suggested because the 
process of pruning is built into your implementation (instead of using 
external threads or comparisons each time you insert)... you're trading 
memory usage for decreased processing time.  On the other hand, it 
doesn't *strictly* tell you how many requests came in the last X seconds 
-- only how many came since the last time unit started.  It's also only 
reasonable for numbers like you suggested -- Tim or Yoav's suggestions 
would be better if your range is 5 seconds to 60 minutes, for example.

justin

At 07:10 AM 7/29/2004, you wrote:
>I need to display on a .jsp page the number of requests for Tomcat in 
>the past 5 / 10 / 15/ 30 / 45 / 60 seconds.  I've already implement a 
>Filter will count the total number of requests.  I did this with a 
>static int, which is incremented everytime a request comes in.  But what 
>should I do so that I can show number of request over past time 
>intervals?  Since the present time is always changing, "the past n 
>seconds" is constantly changing also.
>Thanks in advance,
>Tom


______________________________________________
Justin Ruthenbeck
Software Engineer, NextEngine Inc.
justinr - AT - nextengine DOT com
Confidential. See:
http://www.nextengine.com/confidentiality.php
______________________________________________


---------------------------------------------------------------------
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