Running tasks in the background with lower CPU priority

Posted by Brendon Muir on Stack Overflow See other posts from Stack Overflow or by Brendon Muir
Published on 2010-03-08T03:47:11Z Indexed on 2010/03/08 3:51 UTC
Read the original article Hit count: 363

I have a feature in my CMS that allows a user to upload a zip file full of images and the server will extract them and insert each one into an image gallery. I've noticed that this grinds up the CPU quite severely and causes other requests to slow down.

I'm thinking of using the delayed_job plugin to delegate each image addition into the background, but I also want to give that process a lower CPU priority so that it doesn't bog down the server.

I'm pretty confident in the delaying part of the exercise, but the throttling part is where I'm stuck. Is there a ruby way of lowering the priority of a method call?

It's the image resizing that causes the CPU chew.

Any ideas welcome :)

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about delayed-job