Micah
Micah

Reputation: 1716

Rake task takes significantly longer on Heroku than locally

I have a rake task that takes about 90 seconds locally. It loops through objects and creates a large PG insert SQL, then executes it at the end.

On Heroku heroku run rake my_task it takes about 1.5 hrs (same data as local). I've been researching Heroku and "One-Off Dynos" but I can't find much info on why it would take so long, other than the fact that my app is on the Heroku free plan with only one web dyno and 0 workers.

Its not the insert that takes long, it's the loop beforehand (loop does not have DB calls).

DB is PG Hobby-Basic. Rails 4.2 Ruby 1.9.3p374

Upvotes: 0

Views: 321

Answers (1)

elithrar
elithrar

Reputation: 24290

If you're using a standard-1X dyno or bigger for your web process, you can run one-off tasks on faster dynos, as sorting ~100k objects in Ruby on a free/hobby dyno is likely to stretch it.

This article covers the basics - https://devcenter.heroku.com/articles/one-off-dynos#one-off-dyno-type for setting the dyno size for a one-off dyno.

Upvotes: 2

Related Questions