WestMichiganRubyTraining / discussion

Create issues on this repository to open discussion threads in the Issue Tracker!
2 stars 0 forks source link

background job processing #51

Open ThomasBush opened 10 years ago

ThomasBush commented 10 years ago

I need to do some background job processing. I spoke with @walsh1kt about this in the past, but can't remember what was used. Does anyone have a preference here? I have seen delayed_job, Resque and Sidekiq as possible solutions. Any ideas here or reason I would want to use one over the other? Thanks everyone!

coderbydesign commented 10 years ago

I have used Sidekiq and Delayed Job. I use Delayed Job for most everything, now. Here is a link to some use cases for each: http://stackoverflow.com/a/4810735/1331784

Sidekiq and Resque I believe both use Redis, where Delayed Job does not. Delayed Job has worked great for me and was really simple to setup and get what I needed out of it. I'm just using it to kick off a long background process in a controller, and have a poller setup in the UI to notify the user of progress.

This (taken from the Delayed Job Github page) is essentially what I'm doing:

# without delayed_job
@user.activate!(@device)
# with delayed_job
@user.delay.activate!(@device)
ThomasBush commented 10 years ago

Thanks @walsh1kt, that worked really well! I finally got time to finish my app that generated the pdf spec sheets for our products and this was the last remaining piece of the puzzle. The generation process followed by a save process that kicked the PDFs off to rackspace cloud files took quite a while....not anymore though! I really appreciate the input.

ThomasBush commented 10 years ago

Also may be beneficial to note that I ended up using handle_asynchronously :generate_spec_pdf instead of the .delaymethod as I will always want these processed in the background.

coderbydesign commented 10 years ago

Great to hear! Good call using the asynchronous handler in your case. I wasn't able to do that because I call my method in other places, without needing a background process.