开发者

Quickest way to write logging/stats data - file, database or url to external service

开发者 https://www.devze.com 2023-01-14 01:48 出处:网络
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 over

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 serv开发者_开发知识库ice 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?


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

0

精彩评论

暂无评论...
验证码 换一张
取 消