问题
I need to store more metrics for my web app. User behavior and other conditions needs to be tracked over time and compared.
Some records have a timestamp associated with it, some don't. So an on-demand query for metrics might not be suitable all the time. I think what is needed is a snapshot (daily?) of certain analytics queries (via a cronjob?) that I write and then stored somewhere (DB? file?).
Right now I'm worried about the size of these snapshots if I were to save them in the DB. How will it affect my app's performance?
Admins should be able to view these analytics on a web dashboard. Imagine storing the state of 100,000+ rows of data every day....and then querying them pretty often to do analysis.
Are there other good approaches to storing and viewing metrics? I'm using the LAMP stack for my app. Also using Google Analytics and other 3rd party metric tracking tools but it's not good enough to track specialized statistics for my app.
回答1:
If it is that intensive i would set up a separate DB (possibly on an entirely different server) for the snapshots. If admins are going to view them in a web interface i would probably stick with a DB though. That way you can just run snapshot of base analytic info, then you can build a separate interface/app to query that data further and present it.
As Calvin said in his comment, it would be good have some examples of the data youre recording though as well as how much of it you think there is going to be on the daily. That info might change my thoughts on it.
来源:https://stackoverflow.com/questions/6393439/how-to-store-metrics-for-my-web-app