Heroku Clojure scheduled tasks versus worker threads

273 views
Skip to first unread message

Jonathon McKitrick

unread,
Jun 17, 2013, 8:27:21 PM6/17/13
to clo...@googlegroups.com
How would you sum up the differences?  Does the worker thread simply run all the time?  Wouldn't that run up the dyno usage?

danneu

unread,
Jun 17, 2013, 11:04:04 PM6/17/13
to clo...@googlegroups.com
Heroku cron jobs and workers are prorated like dynos. They run in their own processes. So does booting into heroku bash or heroku console.

Workers generally consume a queue.

I'm not sure what you mean by "worker thread" though. Workers don't run in a thread, and you can launch plain old threads whenever you want to in your Clojure code. Heroku isn't going to bill you for threads. Perhaps I've misunderstood.

Jonathon McKitrick

unread,
Jun 18, 2013, 9:22:44 AM6/18/13
to clo...@googlegroups.com
You are correct, I meant to say 'worker process type' as opposed to 'web process type'.

So, the question then, is what would be the difference between a heroku scheduled command (which I currently am running, wakes up, does some work, etc) and a 'worker process' type?  Does the latter need a job queue set up?  Does it run constantly, checking that queue and consuming work items from it?

danneu

unread,
Jun 19, 2013, 1:49:34 AM6/19/13
to clo...@googlegroups.com
As you suspect, the Heroku cron job launches, executes code, and bills you for its time and the 'worker' process, like the 'web' process, runs at all times.

web:    lein run -m myapp.web
worker: lein run -m myapp.worker

I imagine myapp.worker can just be (while true (println "Working")) for all Heroku cares.

Phil Hagelberg

unread,
Jun 20, 2013, 1:53:45 PM6/20/13
to Clojure
On Jun 18, 6:22 am, Jonathon McKitrick <jmckitr...@gmail.com> wrote:
> So, the question then, is what would be the difference between a heroku
> scheduled command (which I currently am running, wakes up, does some work,
> etc) and a 'worker process' type?  Does the latter need a job queue set up?
>  Does it run constantly, checking that queue and consuming work items from
> it?

The reply from danneu is right; but more specifically you should set
up a worker process type if you've got enough work to keep a process
busy full-time or if you need a quicker turnaround time for the work
you're sending it. A scheduled process will be cheaper in terms of
time consumed, so if you're not currently bothered by its limitations
you should probably stick with it. Either a worker or a scheduled
process can use a queue to get its jobs, or it can get it from a DB if
the volume is low.

-Phil
Reply all
Reply to author
Forward
0 new messages