0

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.

settinghead
  • 95
  • 1
  • 6
  • You can log them to the database in batches. Rather than writing single rows to the DB, write (say) 100 rows at a time. Just so you know, though, 300 requests per minute is _nothing_. – Matt Ball Aug 04 '11 at 04:51

1 Answers1

0

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.

isobar
  • 1,165
  • 8
  • 10