Heroku App Runs Super Slow - High Memory Consumption

Hello Streamlit community!

I’ve recently deployed a streamlit app a friend made to Heroku. It was running just fine last night when I deployed it, but since this morning at 9am (GMT +1), it has started timing out and memory is going through the roof.

It was tweeted by someone with a lot of followers so I suspect it may be a concurrency issue, but I’d love to hear your thoughts.

Here is the memory usage from Heroku:

Thanks!!

Hey @Gulipad,

Welcome to the forum :wave:

Do you have a Heroku graph for the number of connected users or page views for the same time period?

Also, is it possible for you to increase the number of dynos or the performance of the dynos? Other users solved similar memory issues on Heroku via that approach Latency on Heroku. Perhaps you simply need more resources.

If that doesn’t solve it and you see memory usage continually rising and not falling please let us know. However from the graph you shared it looks like the memory is rising and then falling.

Hy @Jonathan_Rhone,

Thanks for your reply! I don’t have the graph, but it wasn’t an insane amount, maybe a few tens at a time, a couple of hundred at most.

I did increase the dynos, but even with 2x performance dynos (~$50 a month) it was quite slow and sluggish (but it didn’t time out).

Each page visit looks like it’ll be reading a lot of CSV files and holding them in memory - a few hundred people at the same time with one meg of data means a few hundred meg in total. You’re also going to have every page load & input change result in lots more network requests to load that data in from github.

Caches are shared, right? You could cache those CSV loads for a start.

1 Like

@Gulipad Actually since it’s an easy change I’ve forked, added caching and put a PR up on your repo.

Needs streamlit 0.57 for the TTL

Amazing! Thanks so much!

No worries. Be warned - I’ve only lightly tested it!