ASA Go: Cache provincial-summary, hfi-stats, and tpi-stats in Redis - #5795
Merged
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5795 +/- ##
==========================================
+ Coverage 68.71% 68.90% +0.18%
==========================================
Files 385 388 +3
Lines 21558 21660 +102
Branches 2935 2937 +2
==========================================
+ Hits 14813 14924 +111
+ Misses 5837 5830 -7
+ Partials 908 906 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



During the same load test that led to #5780,
provincial-summary,hfi-stats, andtpi-statswhich are 7 of the 9-10 requests ASA Go's makes on every launch hits Postgres directly on every single call. All three are read-heavy and keyed to a specific completed SFMS run (run_type/run_datetime/for_date) that never changes once that run finishes, making them ideal candidates to cache rather than re-query.Results are now cached in Redis (
app/auto_spatial_advisory/advisory_run_stats/), keyed on the run identity so a new run naturally gets a new key with no invalidation needed, with a 1-day TTL — following the same patternhfi/fire_centre_cache.pyalready uses elsewhere in the API. The Redis client is built with explicit1sconnect/socket timeouts rather than the sharedcreate_redis()helper's untimed default, so an unreachable Redis fails fast into the existing Postgres path instead of hanging the request's event loop.latest-sfms-run-parametersdeliberately stays uncached, since it's the "what's newest" endpoint and caching it would risk serving a stale answer right after a new run finishes.Test Links:
Landing Page
MoreCast
Percentile Calculator
FireCalc
FireCalc bookmark
Auto Spatial Advisory (ASA)
HFI Calculator
SFMS Insights
Fire Watch
Weather Toolkit