title: How can I count the number of events in a given interval?
body: <p>I need to know how frequency different events occur. For example how many HTTP requests have occurred in the last 15 minutes. Because there can be a large count of events (millions) this must be use a limited amount of memory.</p>
  
  <p>It there any util class in Java that can do this?</p>
  
  <p>How can I implement this self in Java?</p>
  
  <p>Theoretical usage code can look like:</p>
  
  <pre><code>FrequencyCounter counter = new FrequencyCounter( 15, TimeUnit.Minutes );
  ...
  counter.add();
  ...
  int count = counter.getCount();
  </code></pre>
  
  <p>Edit: It must be a real time value which can changed thousand times the minute and will be query thousands times the minute. That a database or file based solution are not possible.</p>