开发者

How to get requests per minute count within java web app

开发者 https://www.devze.com 2023-01-04 19:20 出处:网络
In my particular web app I need a heavy load statistics, such as \"requests per minute\". How to obtain this v开发者_开发问答alue within Servlet API based webapp?Almost all containers allow instrument

In my particular web app I need a heavy load statistics, such as "requests per minute". How to obtain this v开发者_开发问答alue within Servlet API based webapp?


Almost all containers allow instrumentation data to be queried using JMX. It could be you have to install a plugin.

The exact content is container specific, but it is pretty straightforward.

Here are the docs related to tomcat for example.


Well not coming from a servlet background, I would be tempted to do it the old fashioned way: count as you process.

If this was PHP, ASPNET or Django, I would keep a memcache key to store the current minute, and another key for a counter.

When the action you want to track occurs, check to see if the minute is the same as the current one. If it is, increment the counter and if it's not, save the old count to database, save the new current minute and start the counter from zero.

You can extend it quite easily to track different actions by adding the action to the memcache keys.


The easies way to get to these statistics is to configure Tomcat access logs. There are some tools available to parse these logs but you can do requests per minute with a simple script.

0

精彩评论

暂无评论...
验证码 换一张
取 消