views:

21

answers:

1

Hi, I am running a high volume web service and want to track the number of times the service gets called (per customer). However, I want the logging/writing of this data to have minimal impact on the overall time taken to process the service request.

I have thought of three ways:

  1. Write to file (would need to open the file, read the 'hit count', increment and write back)
  2. Write to database (write to a table and increment the 'hit count' against a given customer)
  3. Fire off a URL call to some other service that can worry about storing the data

I like the 3rd option for architecture and coherence, but would firing an HTTP request be more 'costly' than either of the first options 1 or 2?

+1  A: 

You could front the WebService with the Apache HTTP Server, and log requests directly from there. Logging requests would then be 100% ancillary to your application container, meaning no coupling to the application itself. You could track per-customer by looking at request headers and/or parsing/rewriting the URL.

Check out the "Access Log" here: http://httpd.apache.org/docs/2.2/logs.html

rob