Dash/pymongo/heroku

Hello,

I have made a dashboard with dash that I want to deploy on heroku.

My app more or less does:

connect to MongoDB and query it with pymongo
json_normalize the result and create a df
do some manipulations e.g. pivot_table
make graphs with dash

my db query is like this:


results.rewind()
for r in results:
    # mID = r.get('_id')
    # print(mID)
    result.append(r)

where results is a find cursor with some filters and document count is 180k

My issues are:
In Jupyter notebook, everything runs fine but in PyCharm I get a MemoryError towards the end of the loop. I’m not sure why that is the case. Anyway, I deployed it on Heroku and I pretty quickly get R14 (Memory quota exceeded). I’m on the free plan and there are 512 Mb memory free. I think it said my usage was around 700Mb but I’m not sure what was executed and I doubt the above loop was.

My question is, is it possible to deploy it successfully on heroku? Meaning, would 512Mb be enough if my pymongo loop was executed? If not, would the 1Gb plan do it? I’m not exactly sure how the 512Mb memory is used or how to quantify my app. Thanks