Quickest way to write logging/stats data - file, database or url to external service
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:
- Write to file (would need to open the file, read the 'hit count', increment and write back)
- Write to database (write to a table and increment the 'hit count' against a given customer)
- 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
精彩评论