I am currently connecting to a remote mongodb to generate a dashboard in Flask. The db connection and load into Pandas occurs on each page request.
@app.route("/")
#connects to db
#loads to pandas
#perform analysis and display
@app.route("/recent/")
#connects to db
#loads to pandas
#perform analysis and display
Loading the whole dataset into Pandas for each page request is clearly inefficient. The data being loaded does not change frequently (perhaps every 10 minutes or so).
What is the most efficient method / best practice in this situation. Is it possible to define a global function that updates the dataset every x minutes with local functions performing the analysis on the global dataset on each page request?
Thanks.
Aucun commentaire:
Enregistrer un commentaire