Forums

Beginner Question: First load, per day, on web app is slow

I am pretty new to developing my own projects, for a bit of context. :)

I have a flask app that was running slowly on the first load of the day. At first, I thought it had to do with function performance/data caching. But when I added time stamps on the functions, they seem to do okay. But when I looked at the server log, there is a lot going on for the first page load, is this causing the slow down?

I have 5 workers on this app.

Log File

Thank you! <3

What you are describing sounds like you have some heavy processing code which is loaded at the import time, so any time that the app is reloaded by WSGI. You may want to consider separating this code from the web app, as suggested in this help page.

Hmm. The CSV file I am reading from is getting a bit big. That is all I can really see, is that going to bog this down? I thought reading from a static file would be snappy.

Oh... my goodness. I am opening the same large CSV 5 times per load, no wonder it's sluggish. This is on me.

But yes, leveraging tasks is incredibly helpful to offset process times.

Thank you, this is resolved.

Maybe switch from csv file to using database?

I may have to do that, I didn't know that reading from a csv file would bog down an app on this platform the way it has.

Oops, that post came off a bit aggressive, sorry about that. But you are correct that I need to think of a more performant want to handle the data. Thanks!

I do not think that there is anything platform specific here. Just preloading and processing big chunk of data on startup slows down startup.