Introduction to
Resque
Nov. 20, 2009 (Fri.)
Feedforce, Inc.
suzuki@feedforce.jp
Resque
GitHub

Ruby

          Ruby

  JobObj.perform(*args)
                  Redis

git://github.com/defunkt/resque.git
...
Redis
 Key-Value Store

 http://code.google.com/p/redis/
 ANSI C

   POSIX

                                   String, Lis...
Redis
$telnet localhost 6379
SET keyname 3
bar
+OK
GET keyname
$3
bar
Redis
 http://w.koshigoe.jp/study/
GitHub
                                (run/fin)




               fat, old, too long



    push/pop
O(1)   push/pop



Ruby
Resque + Redis
A. Resis


           Redis
Resque

                    WEB

             fork



 Hoptoad

     Redis
DEMO
$ sudo gem install redis redis-namespace yajl-ruby 
 --source=http://gemcutter.org
$ sudo gem install sinatra
$ git c...
DEMO
$ VERBOSE=true QUEUE=default rake resque:work
DEMO
$ VVERBOSE=true QUEUE=default rake resque:work
DEMO
$ open http://localhost:9292/resque/
class Archive
  @queue = :file_serve

 def self.perform(repo_id, branch = 'master')
  repo = Repository.find(repo_id)
  repo...
class Repository
  def async_create_archive(branch)
   Resque.enqueue(Archive, self.id, branch)
  end
end
klass, args = Resque.reserve(:file_serve)
klass.perform(*args) if klass.respond_to? :perform
$ cd app_root
$ QUEUE=file_serve rake resque:work
JSON
{
    'class': 'Archive',
    'args': [ 44, 'masterbrew' ]
}
Resque::Failure

      Redis

Resque     Hoptoad

http://www.hoptoadapp.com/pages/home
Resque vs DelayedJob
Resque


Ruby




Redis
RAM
DelayedJob




Redis
GitHub     (                 )

Ruby           (        )

Redis                        (         )

                   → ...
Introduction to Resque
Upcoming SlideShare
Loading in...5
×

Introduction to Resque

3,454

Published on

社内勉強会での発表に使ったスライドです。
GitHub で使われているジョブキューシステムの Resque について、簡単に説明しています。

0 Comments
7 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
3,454
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
31
Comments
0
Likes
7
Embeds 0
No embeds

No notes for slide

Introduction to Resque

  1. 1. Introduction to Resque Nov. 20, 2009 (Fri.) Feedforce, Inc. suzuki@feedforce.jp
  2. 2. Resque GitHub Ruby Ruby JobObj.perform(*args) Redis git://github.com/defunkt/resque.git WEB
  3. 3. Redis Key-Value Store http://code.google.com/p/redis/ ANSI C POSIX String, List, Set
  4. 4. Redis $telnet localhost 6379 SET keyname 3 bar +OK GET keyname $3 bar
  5. 5. Redis http://w.koshigoe.jp/study/
  6. 6. GitHub (run/fin) fat, old, too long push/pop
  7. 7. O(1) push/pop Ruby
  8. 8. Resque + Redis A. Resis Redis
  9. 9. Resque WEB fork Hoptoad Redis
  10. 10. DEMO $ sudo gem install redis redis-namespace yajl-ruby --source=http://gemcutter.org $ sudo gem install sinatra $ git clone git://github.com/defunkt/resque.git $ cd resque/examples/demo $ rackup config.ru $ open http://localhost:9292/
  11. 11. DEMO $ VERBOSE=true QUEUE=default rake resque:work
  12. 12. DEMO $ VVERBOSE=true QUEUE=default rake resque:work
  13. 13. DEMO $ open http://localhost:9292/resque/
  14. 14. class Archive @queue = :file_serve def self.perform(repo_id, branch = 'master') repo = Repository.find(repo_id) repo.create_archive(branch) end end
  15. 15. class Repository def async_create_archive(branch) Resque.enqueue(Archive, self.id, branch) end end
  16. 16. klass, args = Resque.reserve(:file_serve) klass.perform(*args) if klass.respond_to? :perform
  17. 17. $ cd app_root $ QUEUE=file_serve rake resque:work
  18. 18. JSON { 'class': 'Archive', 'args': [ 44, 'masterbrew' ] }
  19. 19. Resque::Failure Redis Resque Hoptoad http://www.hoptoadapp.com/pages/home
  20. 20. Resque vs DelayedJob
  21. 21. Resque Ruby Redis RAM
  22. 22. DelayedJob Redis
  23. 23. GitHub ( ) Ruby ( ) Redis ( ) → http://w.koshigoe.jp/study/ Resque Redis
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×