Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Do it Later with Resque & Delayed Job

Do it Later with Resque & Delayed Job

A talk I gave at Lone Star Ruby 2012 in Austin, Texas.

Ruby isn't the fastest language on the block, so many systems are built where potentially lengthy operations are done in the background, keeping your application fast and responsive. We take a look at two frameworks for managing background queues and how they can be used effectively in Rails applications.

Ben Scheirman

August 11, 2012
Tweet

More Decks by Ben Scheirman

Other Decks in Programming

Transcript

  1. class Foo def bar puts "baz" end end (irb) >

    Foo.new.delay.bar $BMMFSEFDJEFTBTZOD Saturday, August 11, 12
  2. class Foo def bar puts "baz" end handle_asynchronously :bar end

    (irb) > Foo.new.bar $BMMFSEPFTO`UDBSF Saturday, August 11, 12
  3. class MyJob def perform puts "I'm doing background work!" sleep

    10 end end (irb)> Delayed::Job.enqueue MyJob.new Saturday, August 11, 12
  4. %FpOJOH+PCTJO3FTRVF class SendNewsletterJob @queue = :mailer def self.perform(newsletter_id) newsletter =

    Newsletter.find(newsletter_id) User.subscribed.find_each do |user| UserMailer.newsletter( user, newsletter).deliver end end end Saturday, August 11, 12
  5. *OTUBMMJOH3FEJT 0OB.BD brew install redis 0OUIFTFSWFS 6CVOUV wget http://redis.googlecode.com/files/redis-2.4.13.tar.gz tar

    xzvf redis-2.4.13 cd redis-2.4.13 make sudo make install )PTUFEXJUI3FEJT5P(P IUUQSFEJTUPHPDPN Saturday, August 11, 12
  6. 4JEFLJR .BTUFS 1SPDFTT 8PSLFS 8PSLFS 8PSLFS 8PSLFS 8PSLFS 8PSLFS 8PSLFS

    8PSLFS 8PSLFS 8PSLFS 8PSLFS 8PSLFS 8PSLFS 8PSLFS 8PSLFS 8PSLFS 8PSLFS 8PSLFS 8PSLFS 8PSLFS Saturday, August 11, 12