I want to show my users some statistics such as hits/second on Google App Engine. I started to roll my own:
- On each page view, add 1 to a count in memcache.
Each minute:
- Read and reset the count and also set a “since” variable to now.
- Divide the number of hits by the amount of time since I last calculated.
- Save the data to an entity in the datastore.
- Throwing out data that’s really old.
I then realised that this is non-trivial and there must be a library to do it, however I can’t find one that works for me. I looked briefly at rrd4j and JRobin but I’m not sure they they’re usable on Google App Engine without quite a lot of rewriting. Does anyone have any more ideas?
I seem to remember Twitter commons has what you need, but I don’t know if they could be easily portable to GAE: https://github.com/twitter/commons