Dave
Dave

Reputation: 11862

Background processing on a nodejs, mongodb and heroku stack

I'm writing a simple image upload site as a learning project.

It's written in nodejs, with mongodb and deployed onto Heroku cedar.

I'd like to implement a node script that runs say, once an hour, and applies the reddit algorithm to images and stores the score against each image in mongodb.

How can I achieve this bearing in mind I am on heroku and have file system limitations? - Given the cedar architecture, it would be best to hand off to a separate worker, but if there's a faster/simpler/easier approach I'd be happy to hear it. The heroku dev center article on workers/background jobs unfortunately doesn't list any tutorials yet for such a system.

My previous experience of background processing on heroku was with rails - so scheduled tasks add-on, + delayed_job and it's very straight forward.

Upvotes: 3

Views: 1887

Answers (1)

Kevin Reilly
Kevin Reilly

Reputation: 6252

An extremely simple approach might utilize setInterval or node-cron. You might also want to spawn or fork a child process for this periodic processing.

Upvotes: 3

Related Questions