In my particular web app I need a heavy load statistics, such as “requests per minute”. How to obtain this value within Servlet API based webapp?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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.