I trained a ML learning model using Python (sk-learn) that I want to host on the web so users can get predictions based on their input. So far, I managed to deploy it using Heroku in a simple NodeJS / Express web app. I am using a ChildProcess to trigger the Python process from Node. However, this is working rather slow (~5 seconds). I assume this is because the models have to be loaded again and again on every request.
Is there anything I can do to improve this set-up while keeping Node in the stack?
Or is it necessary to switch to something like Flask so everything is in Python and the models can just be loaded on start-up? (Which is what is advised here: Sklearn Model (Python) with NodeJS (Express): how to connect both?)
Update I switched to Flask which on the one hand solves the issue of reloading, but it also brought to light that my models (Random Forest) require too much memory to run comfortably on Heroku. Which is a new issue.