Resque Intro

Resque Intro

Done @ Apero Ruby Lille

Fd6c3e14f1aafe3ce6e9084291096df6?s=128

Robin Komiwes

October 31, 2012
Tweet

Transcript

  1. RESQUE /ˈrɛskyu/

  2. J 4228 700+ forks defunktocat defunkt/resque

  3. DelayedJob SQS Starling ActiveMessaging BackgroundJob Beanskalkd RESQUE

  4. Background jobs JSON pending jobs in Redis Ruby multiples Queues

    Persistents Workers Classes that respond to `perform`
  5. # lib/resque/archive.rb class Archive @queue = :file_serve def self.perform(repo_id, branch

    = 'master') repo = Repository.find(repo_id) repo.create_archive(branch) end end # app/models/repository.rb class Repository def async_create_archive(branch) Resque.enqueue(Archive, self.id, branch) end end
  6. RESQUE-WEB

  7. Steve Klabnik "Yet Another GitHub Project They've Open Sourced and

    Then Abandoned." But Resque is super awesome [...] http://blog.steveklabnik.com/posts/2012-09-22-resque--let-s-do-this
  8. Fresc | Smart Images Feedback RESQUE 5 workers 10+ ≠

    queues
  9. Asynchronous manipulation upload to CDN Emails delivering Images PDF reports

    generation ...
  10. plugins resque-scheduler resque-retry resque-mailer resque-lock

  11. daily_digest: cron: "0 */24 * * *" class: Digest description:

    "The one time a day activity digest" args: [1] bidaily_digest: cron: "0 */12 * * *" class: Digest description: "The two time a day activity digest" args: [2] instant_digest: cron: "*/5 * * * *" class: Digest description: "Send each 5 minuts a digest" args: [3]
  12. module UploadImageToCdn extend Resque::Plugins::ExponentialBackoff @queue = :cdn_upload @backoff_strategy = [0,

    0, 0, 0.5, 1, 2, 5, 10] def perform( image_id ) # ... end extend self end
  13. class UserMailer < ActionMailer::Base include Resque::Mailer # ... end

  14. require 'resque/plugins/lock' module SummarizeProject extend Resque::Plugins::Lock @queue = :summarize_project def

    perform( gallery_id ) gallery = Gallery.find( gallery_id ) gallery.summarize end extend self end
  15. Run | development ★ rake task to start workers

  16. Run | production ★ Configure Upstart to auto-restart workers when

    they are down. ★ Capistrano deploy hook to shutdown running workers. after "deploy:create_symlink", "deploy:stop_resque"
  17. @robinkomiwes robin.komiwes@gmail.com