I want to be able to log usage statistics for a Java-based API service. The estimated request rate is between 10 and 300 per minute, and will potentially grow to a much higher number. I do not need detailed analytics, just a simple hit counter that logs number of hits at a specified time interval, so that I will be able to draw a graph of usage rate against time.
I understand that one possibility would be log hits in MySQL or a dump file, but I feel this could have potential performance issues as MySQL requests seem expensive. Is there a better solution? I have looked around the web but haven't found a good answer.
Use an async logger with buffer size so you do batch operations.
http://www.spartanjava.com/2009/asynchronous-logging-with-log4j/
You can directly dump it to mysql. This can be triggered as a parallel process without disturbing your main app.