by holden_nelson on 12/28/21, 4:33 AM with 3 comments
I'm having a hard time figuring out how to make this all happen quickly. While I'm certain there are optimizations that can be made in my Python code, I'd like to find some way to be able to make multiple calculations on reasonably large sets of objects without making the user wait like 10 seconds.
The problem is that the data can change in a given moment. If the user makes changes to their data in the other software, there is no way for me to know that without hitting the API again for that info. So I don't see a way that I can cache information or pre-fetch it without making a ridiculous number of requests to the API.
In a perfect world the API would have webhooks I could use to watch for data changes but that's not an option.
Is my best bet to just optimize the factors I control to the best of my ability and hope my users can live with it?
by delbronski on 1/3/22, 2:44 PM
by Southland on 12/28/21, 4:53 AM
- Find the amount of time a user can still view a non real-time report. If the report timeframe is days then you can simply show the last full day. Even if it is real-time, using a small TTL and avoiding the recalculation on every refresh will help. Personally, I think users are forgiving with some lag between actions and reporting.
“ I'd like to find some way to be able to make multiple calculations on reasonably large sets of objects without making the user wait like 10 seconds.”
- If you can’t get it fast enough, then avoid your calculations in Python over large data objects you need to always have loaded in memory. Moving the raw data into a database better suited for the aggregations/calculations needed could reduce the time your user has to wait.
by NicoJuicy on 12/28/21, 5:47 AM
Let them click if they want the updated data if aggregating it is resource intensive.
If it's a SAAS make the polling internal dependant on their subscription.