views:

26

answers:

1

Howdy,

I have a simple enough web application. I want to measure for any day or month how many new free signups I have, how many paid signups, how many paid upgrades, how many cancellations, etc. That data will then be represented on my admin dashboard by sparklines.

Generally, do you suggest:

a) Writing a script that upon each call, anlyses the raw database data and creates statistics for the time period?

b) Running a daily cron job to record, for example, the number of new signups that day, and then using that simplified data to create the sparklines?

Thanks.

+1  A: 

Well it depends on whatever use you are going to have for those statistics:

  • If you want to monitor what happens in your system, calculate on the fly if you can, so you can know at any moment what is going on in your database.

  • If you want to analyze your data, it is better to precalculate the statistics in a periodic job, so you basically work with a snapshot of the data at a certain moment. Otherwise you would get moving data which is difficult to work with.

gpeche
You can also have a mix of both, I actually have a system running where stats are calculated when you access them but saved so that the next access will require only recalculating the last uncomplete period. This is interesting if you want to do monitoring but have too much row data to be crunched at once (and you can setup a cron job as well to make sure stats are calculated at least once a day).
Claude Vedovini