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

Procrastinate your code: Do it later.

zmoazeni
August 12, 2011

Procrastinate your code: Do it later.

You can't do it all. Sometimes breaking the request/response cycle is just too constraining and you need to bust out of it. Enter asynchronous processing.

Delayed Job and Resque, two takes at solving this problem, are popular tools. We'll explore their differences, demonstrate how to get up and running in minutes, and show you how to find the best fit for your project.

zmoazeni

August 12, 2011
Tweet

More Decks by zmoazeni

Other Decks in Programming

Transcript

  1. Procrastinate Your Code! Do it later Zach Moazeni Collective Idea

    Lonestar Ruby August 12, 2011 with Delayed Job and Resque
  2. class Dog < ActiveRecord::Base def bark(when) ... end handle_asynchronously :bark

    end Dog.find(1).bark(2.hours.from_now) calls .delay() for you
  3. class MyJob @queue = :background def self.perform(...) ... end end

    > Resque.enqueue(MyJob, ...) > QUEUE=* rake resque:work
  4. class MyJob @queue = :background ... end class ImportantJob @queue

    = :important ... end > QUEUE=important,background rake resque:work
  5. People to Thank DelayedJob Tobias Lütke Collective Idea Brandon Keepers

    Matt Griffin Resque Chris Wanstrath Github Tons of Plugin Devs
  6. Image Credits Kid Hiding: http://www.flickr.com/photos/bart_/1477582337/ Pizza in oven: http://failblog.org/2011/07/27/epic-fail-photos- classic-pizza-baking-fail/

    Phusion Passenger: http://www.modrails.com/ Bacon and Cheese Stuffed Pizza Burger: http:// www.epicmealtime.com/ Email: http://www.flickr.com/photos/m-c/2250563337/ spreadsheet: http://www.flickr.com/photos/jacobchristensen/ 162595896/ Image Grid: http://www.flickr.com/photos/leoboiko/ 3472849221/ Construction Worker: http://www.flickr.com/photos/jprod/ 5212302797/ Do it live: http://www.flickr.com/photos/torley/2578472833/ Queue: http://www.flickr.com/photos/richardsummers/ 269503769/ Heroku: http://www.heroku.com/ Redis: http://redis.io/ Traffic: http://www.flickr.com/photos/epsos/5591761716/ Lego Deployment: http://www.flickr.com/photos/elsie/4354094625/ Buddy Christ: http://www.flickr.com/photos/wishmerhill/389515893/ Monit Logo: http://mmonit.com/monit/ Wall Plug: http://www.flickr.com/photos/tolomea/4222795245/ Lego at Computer: http://www.flickr.com/photos/leftclicker/5874546452/ Live Roleplay: http://www.flickr.com/photos/nothakus/5526792671/ Blue Screen: http://www.flickr.com/photos/albertoalerigi/5711263109/ Fake Mobius Strip: http://www.flickr.com/photos/jgoforth/96136090/ Bunnies: http://www.flickr.com/photos/29278394@N00/696701369/ Pencil: http://www.flickr.com/photos/25073464@N05/2776574771/ Delorian: http://www.flickr.com/photos/codepo8/5114310672/ Square Peg: http://www.flickr.com/photos/epublicist/3546059144/