eoinoc
eoinoc

Reputation: 3265

Should I compute statistics on the fly, or generate with a cron job?

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.

Upvotes: 4

Views: 389

Answers (1)

gpeche
gpeche

Reputation: 22514

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.

Upvotes: 4

Related Questions