XGBoost classifier on heroku dyno takes too much time to fit

We are working on a project were we have to build models which can work with any subset of the columns. We have chosen the XGBoost classifier, and our idea was to build a new model after selecting the subset of the columns only using the selected columns. Our dataset is small, 1600 rows and 25 columns, so our method works relatively fast. We have made an application with streamlit for this project. We can specify which columns we want to use and then give the predictions. Running this application local works fine, and gives the results pretty fast. But it runs very slow on heroku, because fitting the XGB model takes a lot of time on the dyno. We have no idea why does the fitting take nearly 100x more time on heroku. Every other part of the code runs pretty fast on heroku aswell, only the xgb.fit(X_train_temp2,y_train_temp2) line runs very slow. What could be the reason, which makes the fitting process on heroku really slow?

It could be that the Heroku Dyno is not optimized for compute-intensive workload, such as fitting an XGBoost model. Which type of Dyno are you using? You may consider off-loading compute-intensive workload to services like DigitalOcean or AWS EC2, where you can pick a machine that’s CPU-optimized (“CPU-Optimized” tier for DigitalOcean Droplet; C5 instance type for AWS EC2).