Fetch dashboard daily stats from Redis with DB as fallback - #2693
Fetch dashboard daily stats from Redis with DB as fallback#2693whabanks wants to merge 5 commits into
Conversation
🧪 Review environmenthttps://bd36m4cy7sa6yvunmsdiakbxbe0vukyc.lambda-url.ca-central-1.on.aws/ |
Oh yea they are a little bit off... I tried deleting and re-seeding the data in Redis but it seems the counting may be off. I'll dig into it and see if I can find where the seeding differs from what the DAO fetches. |
It seems like the difference we're seeing is because of notifications with a non-terminal statuses i.e. inflights - referred to as requested in code. Some thoughts on options moving forward:
|


Summary | Résumé
This PR tweaks
_get_daily_statsto improve performance. Instead of a round trip to the DB to fetch the daily stats, we first attempt to fetch them from Redis using theRedisAnnualLimitclient with the DB as a fallback.Perf timings before (measured on staging directly):
{ "template_statistics_weekly": 1400.3448486328125, "aggregate_template_usage": 5.429983139038086, "get_scheduled_jobs": 45.98712921142578, "get_immediate_jobs": 32.1347713470459, "add_rate_to_job": 0.000476837158203125, "_get_daily_stats": 1246.3033199310303, <--- "weekly_stats_aggregation": 3.3087730407714844, "get_bounce_rate_data": 13.918161392211914, "get_annual_data": 3.88336181640625 }Perf timings after (measured with this branch hooked up to staging):
{ "template_statistics_weekly": 3350.5444526672363, "aggregate_template_usage": 4.066944122314453, "get_scheduled_jobs": 147.20726013183594, "get_immediate_jobs": 182.31868743896484, "add_rate_to_job": 0.000476837158203125, "_get_daily_stats": 62.27922439575195, <-- "weekly_stats_aggregation": 2.112865447998047, "get_bounce_rate_data": 346.47130966186523, "get_annual_data": 93.42670440673828 }Test instructions | Instructions pour tester la modification
Basic tests
/services/8dad0c16-6952-4424-be2a-d98b8bfc3c2din bothPerf via logs
/services/8dad0c16-6952-4424-be2a-d98b8bfc3c2d