Should I calculate statistics on the fly or generate using cron job?

I have a fairly simple web application. I want to measure during any day or month the number of new free subscribers, how many payment registrations I have, how many paid updates, how many canceled, etc. This data will be presented on the administrator’s control panel for spark lines.

Typically, you offer:

a) Writing a script that, with each call, analyzes the raw data of the database and creates statistics for a period of time?

b) Performing a daily cron job to record, for example, the number of new registrations that day, and then using these simplified data to create light lines?

Thanks.

+4
source share
1 answer

Well, it depends on what use you will have for this statistic:

  • If you want to keep track of what is happening in your system, count on the fly if you can, so that you can find out what is happening in your database at any time.

  • If you want to analyze your data, it is better to pre-calculate the statistics in a periodic task, so you mainly work with a snapshot of the data at a certain point. Otherwise, you will get moving data that is difficult to work with.

+4
source

All Articles