AmericanRedCross / tasking-manager-stats

BSD 3-Clause "New" or "Revised" License
3 stars 1 forks source link

Tasking Manager Integration #1

Open nbumbarger opened 8 years ago

nbumbarger commented 8 years ago

@dodobas --

Thanks for the database dump. Below is a rundown of benchmarking against the database to test the queries that will allow integration into the Missing Maps stats API.

As far as we can tell, the most efficient way to grab this information would be to pull all the relevant records from the task_state table.

Right now we're grabbing the stats we need by user (instead of by project) through the following query:

SELECT user_id, project_id, state, date FROM task_state WHERE user_id IS NOT NULL AND state IN (1, 2, 3)

Benchmarks

Based on my tests, the database query itself seems to take around 1.0045 seconds on a midrange Macbook Pro. Then processing into an object for the API takes another 0.434 seconds (total of (1.438 seconds), and finally running jsonify to serve it takes another 3.404 (total of 4.842).

Next Steps

Based on these results, couple questions:

  1. If running this every 5-10 mins, do you see this as an impact on the system?
  2. If it can stay around a total of ~5secs to process everytime, do we want to just proceed with running this in the short term as a scheduled task outside of Tasking Manager? In the longer term it seems like if robust API access is interesting, a refactor of the database would enable better integration of per user stats.

cc @kamicut @smit1678

dodobas commented 8 years ago

In any case if this becomes a problem it's possible to solve it upstream (on the load balancer)

Please go ahead and create a PR for this feature