SlideShare uma empresa Scribd logo
1 de 81
Resque
High-performance asynchronous task queuing and
                  processing
Resque
High-performance asynchronous task queuing and
                  processing
Resque
High-performance asynchronous task queuing and
                  processing
Experts
Experts
‘Cause you might build the next GitHub
Three Things
1. Background
Why run background processes at all?
2. Delayed::Job
Because it’s the foundation for Resque
3. Resque
Process different.
1. Background

   Why?
1. Background

It’s all about the ms
1. Background

    It’s all about the ms
• Resize an image
1. Background

    It’s all about the ms
• Resize an image
• Send an e-mail
1. Background

    It’s all about the ms
• Resize an image
• Send an e-mail
• Communicate with a web service
1. Background

    It’s all about the ms
• Resize an image
• Send an e-mail
• Communicate with a web service
• Geocode a location
1. Background

Do something later
    than now
1. Background
1. Background

 Webpages.
1. Background

       Webpages.
Rails serves webpages.
                     Memories. You're
                      talkin about
                       memories.
1. Background
1. Background

1. Receive requests
1. Background

1. Receive requests
 2. Send responses
1. Background

Everything else can go
      elsewhere
1. Background

  Where?
1. Background

         Where?
• CRON
1. Background

               Where?
• CRON
• Beanstalkd
1. Background

               Where?
• CRON
• Beanstalkd
• Workling
1. Background

           Where?
• CRON
• Beanstalkd
• Workling
• BackgroundRB
1. Background

WTF my tasks r fail?!1
1. Background

WTF my tasks r fail?!1
• Silent failure
1. Background

WTF my tasks r fail?!1
• Silent failure
• No status checks
1. Background

WTF my tasks r fail?!1
• Silent failure
• No status checks
• Unstable processes
2. Delayed::Job

To the rescue!
2. Delayed::Job

To the rescue!
2. Delayed::Job

ActiveRecord::Base’d
2. Delayed::Job

 ActiveRecord::Base’d

• Persistence! At last!
2. Delayed::Job

 ActiveRecord::Base’d

• Persistence! At last!
• Ease of use! At last!
2. Delayed::Job

 How easy?
2. Delayed::Job

            Super easy.
# without delayed_job
Notifier.deliver_signup(@user)

# with delayed_job
Notifier.send_later :deliver_signup, @user
2. Delayed::Job

Where do they go?
2. Delayed::Job
mysql> SELECT * FROM delayed_jobs;
*************************** 1. row ***************************
        id: 1
  priority: 0
  attempts: 0
   handler: --- !ruby/object:WorkerBee <-- Notice the pretty Marshal dump
n: 18

last_error: NULL
    run_at: 2010-03-10 22:44:30
 locked_at: NULL
 failed_at: NULL
 locked_by: NULL
created_at: 2010-03-10 22:44:30
updated_at: 2010-03-10 22:44:30
1 row in set (0.00 sec)
2. Delayed::Job

What do you do with
      them?
2. Delayed::Job

  What do you do with
        them?
$ script/delayed_job start
2. Delayed::Job

     Workers.
2. Delayed::Job

     Workers.
    • Live in their own thread
2. Delayed::Job

     Workers.
    • Live in their own thread
    • Query the database for jobs
2. Delayed::Job

     Workers.
    • Live in their own thread
    • Query the database for jobs
    • Perform the long-running task
      away from request/response
The Old Way
The New Way


Delayed::Job
2. Delayed::Job


 Totally rad.
3. Resque

Isn’t Delayed::Job
      enough?
3. Resque

Isn’t Delayed::Job
      enough?
3. Resque


Apparently not.
3. Resque

   Resque is some
Enterprise Grade shit.
3. Resque


Runs on Redis
3. Resque


Runs on Redis
Tangent Alert: Redis!

Redis is a Key-Value
        Store
      Just like Memcached
Tangent Alert: Redis!

    Persistence
      Unlike Memcached
Tangent Alert: Redis!

               Scalability
           The Gem load balances for you


Resque.redis = DistRedis.new(
  :hosts=> %w{192.168.1.22:6379 192.168.1.23:6379}
)
Tangent Alert: Redis!

      Basically:
 Fast & Distributed
Tangent Alert: Redis!

Also, Rails-independent
No ActiveRecord/ActiveSupport means you can run
Resque (on Redis) in Sinatra or any other Ruby app
3. Resque

Better Workers
3. Resque

      Better Workers
• Forked, sandboxed threads
3. Resque

      Better Workers
• Forked, sandboxed threads
• Failing tasks are tracked
3. Resque

      Better Workers
• Forked, sandboxed threads
• Failing tasks are tracked
• Kills timeouts
3. Resque

                 Queueing
          Separate queues for separate workers



fileserver$ QUEUE=zip_files rake resque:work
 webserver$ QUEUE=cache_images rake resque:work
3. Resque

         No Marshaling
          Because it should be functional



Resque.enqueue(SignupNotifier, @user.id)
3. Resque

         No Marshaling
class SignupNotifier
  def self.perform(user_id)
    Notifier.deliver_signup(User.find(user_id))
  end
end
3. Resque

                UI
That’s right. It has its own interface.
3. Resque

So... why?
3. Resque

           So... why?
• Many background tasks
3. Resque

            So... why?
• Many background tasks
• Distributed task servers
3. Resque

            So... why?
• Many background tasks
• Distributed task servers
• Stable workers
3. Resque

Trouble Points
3. Resque

      Trouble Points
• Complex and expensive
3. Resque

        Trouble Points
• Complex and expensive
• No scheduling or priority like in D::J
3. Resque

       Trouble Points
• Complex and expensive
• No scheduling or priority like in D::J
• Asynchronous Redis writes don’t guarantee
  persistence
3. Resque

Live coding FTW!
    Here goes nothing...
Thnaks
Thanks for taking the time to listen to me blather
                 about Resque!
Me!
  Github:    http://github.com/flipsasser
Homepage:    http://x451.com
  Twitter:   @flipsasser
   E-mail:   flip@intridea.com
Bmore on Rails

  Meetups - 2nd Tuesday
  #OSHN - 4th Tuesday

http://www.meetup.com/bmore-on-rails/

Mais conteúdo relacionado

Mais procurados

eZ Publish 5: from zero to automated deployment (and no regressions!) in one ...
eZ Publish 5: from zero to automated deployment (and no regressions!) in one ...eZ Publish 5: from zero to automated deployment (and no regressions!) in one ...
eZ Publish 5: from zero to automated deployment (and no regressions!) in one ...Gaetano Giunta
 
Ruby On Rails Overview
Ruby On Rails OverviewRuby On Rails Overview
Ruby On Rails Overviewjonkinney
 
Why I will never write JavaScript ever again*
Why I will never write JavaScript ever again*Why I will never write JavaScript ever again*
Why I will never write JavaScript ever again*The Wolff
 
Use all the buzzwords
Use all the buzzwordsUse all the buzzwords
Use all the buzzwordsJared Faris
 
Avoiding Common Pitfalls in Ember.js
Avoiding Common Pitfalls in Ember.jsAvoiding Common Pitfalls in Ember.js
Avoiding Common Pitfalls in Ember.jsAlex Speller
 
Kevin Whinnery: Write Better JavaScript
Kevin Whinnery: Write Better JavaScriptKevin Whinnery: Write Better JavaScript
Kevin Whinnery: Write Better JavaScriptAxway Appcelerator
 
Untangling spring week9
Untangling spring week9Untangling spring week9
Untangling spring week9Derek Jacoby
 
Copass + Ruby on Rails = &lt;3 - From Simplicity to Complexity
Copass + Ruby on Rails = &lt;3 - From Simplicity to ComplexityCopass + Ruby on Rails = &lt;3 - From Simplicity to Complexity
Copass + Ruby on Rails = &lt;3 - From Simplicity to ComplexityAugustin Riedinger
 
Untangling spring week10
Untangling spring week10Untangling spring week10
Untangling spring week10Derek Jacoby
 

Mais procurados (11)

eZ Publish 5: from zero to automated deployment (and no regressions!) in one ...
eZ Publish 5: from zero to automated deployment (and no regressions!) in one ...eZ Publish 5: from zero to automated deployment (and no regressions!) in one ...
eZ Publish 5: from zero to automated deployment (and no regressions!) in one ...
 
Ruby On Rails Overview
Ruby On Rails OverviewRuby On Rails Overview
Ruby On Rails Overview
 
Ember & WebComponents
Ember & WebComponentsEmber & WebComponents
Ember & WebComponents
 
Do you queue
Do you queueDo you queue
Do you queue
 
Why I will never write JavaScript ever again*
Why I will never write JavaScript ever again*Why I will never write JavaScript ever again*
Why I will never write JavaScript ever again*
 
Use all the buzzwords
Use all the buzzwordsUse all the buzzwords
Use all the buzzwords
 
Avoiding Common Pitfalls in Ember.js
Avoiding Common Pitfalls in Ember.jsAvoiding Common Pitfalls in Ember.js
Avoiding Common Pitfalls in Ember.js
 
Kevin Whinnery: Write Better JavaScript
Kevin Whinnery: Write Better JavaScriptKevin Whinnery: Write Better JavaScript
Kevin Whinnery: Write Better JavaScript
 
Untangling spring week9
Untangling spring week9Untangling spring week9
Untangling spring week9
 
Copass + Ruby on Rails = &lt;3 - From Simplicity to Complexity
Copass + Ruby on Rails = &lt;3 - From Simplicity to ComplexityCopass + Ruby on Rails = &lt;3 - From Simplicity to Complexity
Copass + Ruby on Rails = &lt;3 - From Simplicity to Complexity
 
Untangling spring week10
Untangling spring week10Untangling spring week10
Untangling spring week10
 

Destaque

Open Source 2.0
Open Source 2.0Open Source 2.0
Open Source 2.0samof76
 
In the Back of Your Mind
In the Back of Your MindIn the Back of Your Mind
In the Back of Your MindJames Gray
 
Supervisord, The Process Manager
Supervisord, The Process ManagerSupervisord, The Process Manager
Supervisord, The Process Managersamof76
 
Gearman, Supervisor and PHP - Job Management with Sanity!
Gearman, Supervisor and PHP - Job Management with Sanity!Gearman, Supervisor and PHP - Job Management with Sanity!
Gearman, Supervisor and PHP - Job Management with Sanity!Abu Ashraf Masnun
 
Brugnoli System Ux
Brugnoli System UxBrugnoli System Ux
Brugnoli System Uxfrog
 
2015 ZendCon - Do you queue
2015 ZendCon - Do you queue2015 ZendCon - Do you queue
2015 ZendCon - Do you queueMike Willbanks
 
MNPHP Scalable Architecture 101 - Feb 3 2011
MNPHP Scalable Architecture 101 - Feb 3 2011MNPHP Scalable Architecture 101 - Feb 3 2011
MNPHP Scalable Architecture 101 - Feb 3 2011Mike Willbanks
 

Destaque (8)

Open Source 2.0
Open Source 2.0Open Source 2.0
Open Source 2.0
 
In the Back of Your Mind
In the Back of Your MindIn the Back of Your Mind
In the Back of Your Mind
 
Job_Queues
Job_QueuesJob_Queues
Job_Queues
 
Supervisord, The Process Manager
Supervisord, The Process ManagerSupervisord, The Process Manager
Supervisord, The Process Manager
 
Gearman, Supervisor and PHP - Job Management with Sanity!
Gearman, Supervisor and PHP - Job Management with Sanity!Gearman, Supervisor and PHP - Job Management with Sanity!
Gearman, Supervisor and PHP - Job Management with Sanity!
 
Brugnoli System Ux
Brugnoli System UxBrugnoli System Ux
Brugnoli System Ux
 
2015 ZendCon - Do you queue
2015 ZendCon - Do you queue2015 ZendCon - Do you queue
2015 ZendCon - Do you queue
 
MNPHP Scalable Architecture 101 - Feb 3 2011
MNPHP Scalable Architecture 101 - Feb 3 2011MNPHP Scalable Architecture 101 - Feb 3 2011
MNPHP Scalable Architecture 101 - Feb 3 2011
 

Semelhante a Asynchronous Awesome

Lessons Learnt in 2009
Lessons Learnt in 2009Lessons Learnt in 2009
Lessons Learnt in 2009pratiknaik
 
A Case Study of NoSQL Adoption: What Drove Wordnik Non-Relational?
A Case Study of NoSQL Adoption: What Drove Wordnik Non-Relational?A Case Study of NoSQL Adoption: What Drove Wordnik Non-Relational?
A Case Study of NoSQL Adoption: What Drove Wordnik Non-Relational?DATAVERSITY
 
My Site is slow - Drupal Camp London 2013
My Site is slow - Drupal Camp London 2013My Site is slow - Drupal Camp London 2013
My Site is slow - Drupal Camp London 2013hernanibf
 
Parallel batch processing with spring batch slideshare
Parallel batch processing with spring batch   slideshareParallel batch processing with spring batch   slideshare
Parallel batch processing with spring batch slideshareMorten Andersen-Gott
 
What Drove Wordnik Non-Relational?
What Drove Wordnik Non-Relational?What Drove Wordnik Non-Relational?
What Drove Wordnik Non-Relational?DATAVERSITY
 
Running MongoDB in the Cloud
Running MongoDB in the CloudRunning MongoDB in the Cloud
Running MongoDB in the CloudTony Tam
 
2013.09.10 Giraph at London Hadoop Users Group
2013.09.10 Giraph at London Hadoop Users Group2013.09.10 Giraph at London Hadoop Users Group
2013.09.10 Giraph at London Hadoop Users GroupNitay Joffe
 
2013 06-03 berlin buzzwords
2013 06-03 berlin buzzwords2013 06-03 berlin buzzwords
2013 06-03 berlin buzzwordsNitay Joffe
 
My site is slow
My site is slowMy site is slow
My site is slowhernanibf
 
Hard Coding as a design approach
Hard Coding as a design approachHard Coding as a design approach
Hard Coding as a design approachOren Eini
 
Redis + Apache Spark = Swiss Army Knife Meets Kitchen Sink
Redis + Apache Spark = Swiss Army Knife Meets Kitchen SinkRedis + Apache Spark = Swiss Army Knife Meets Kitchen Sink
Redis + Apache Spark = Swiss Army Knife Meets Kitchen SinkDatabricks
 
Building Efficient and Reliable Crawler System With Sidekiq Enterprise
Building Efficient and Reliable Crawler System With Sidekiq EnterpriseBuilding Efficient and Reliable Crawler System With Sidekiq Enterprise
Building Efficient and Reliable Crawler System With Sidekiq EnterpriseGary Chu
 
Rails performance at Justin.tv - Guillaume Luccisano
Rails performance at Justin.tv - Guillaume LuccisanoRails performance at Justin.tv - Guillaume Luccisano
Rails performance at Justin.tv - Guillaume LuccisanoGuillaume Luccisano
 
Modern Web technologies (and why you should care): Megacomm, Jerusalem, Febru...
Modern Web technologies (and why you should care): Megacomm, Jerusalem, Febru...Modern Web technologies (and why you should care): Megacomm, Jerusalem, Febru...
Modern Web technologies (and why you should care): Megacomm, Jerusalem, Febru...Reuven Lerner
 
BTV PHP - Building Fast Websites
BTV PHP - Building Fast WebsitesBTV PHP - Building Fast Websites
BTV PHP - Building Fast WebsitesJonathan Klein
 
Ruby's Concurrency Management: Now and Future
Ruby's Concurrency Management: Now and FutureRuby's Concurrency Management: Now and Future
Ruby's Concurrency Management: Now and FutureKoichi Sasada
 
Fault Tolerance in Distributed Environment
Fault Tolerance in Distributed EnvironmentFault Tolerance in Distributed Environment
Fault Tolerance in Distributed EnvironmentOrkhan Gasimov
 
Celery: The Distributed Task Queue
Celery: The Distributed Task QueueCelery: The Distributed Task Queue
Celery: The Distributed Task QueueRichard Leland
 
Modern Web Technologies — Jerusalem Web Professionals, January 2011
Modern Web Technologies — Jerusalem Web Professionals, January 2011Modern Web Technologies — Jerusalem Web Professionals, January 2011
Modern Web Technologies — Jerusalem Web Professionals, January 2011Reuven Lerner
 
How we migrated Zalando app to Swift3?
How we migrated Zalando app to Swift3?How we migrated Zalando app to Swift3?
How we migrated Zalando app to Swift3?Vijaya Prakash Kandel
 

Semelhante a Asynchronous Awesome (20)

Lessons Learnt in 2009
Lessons Learnt in 2009Lessons Learnt in 2009
Lessons Learnt in 2009
 
A Case Study of NoSQL Adoption: What Drove Wordnik Non-Relational?
A Case Study of NoSQL Adoption: What Drove Wordnik Non-Relational?A Case Study of NoSQL Adoption: What Drove Wordnik Non-Relational?
A Case Study of NoSQL Adoption: What Drove Wordnik Non-Relational?
 
My Site is slow - Drupal Camp London 2013
My Site is slow - Drupal Camp London 2013My Site is slow - Drupal Camp London 2013
My Site is slow - Drupal Camp London 2013
 
Parallel batch processing with spring batch slideshare
Parallel batch processing with spring batch   slideshareParallel batch processing with spring batch   slideshare
Parallel batch processing with spring batch slideshare
 
What Drove Wordnik Non-Relational?
What Drove Wordnik Non-Relational?What Drove Wordnik Non-Relational?
What Drove Wordnik Non-Relational?
 
Running MongoDB in the Cloud
Running MongoDB in the CloudRunning MongoDB in the Cloud
Running MongoDB in the Cloud
 
2013.09.10 Giraph at London Hadoop Users Group
2013.09.10 Giraph at London Hadoop Users Group2013.09.10 Giraph at London Hadoop Users Group
2013.09.10 Giraph at London Hadoop Users Group
 
2013 06-03 berlin buzzwords
2013 06-03 berlin buzzwords2013 06-03 berlin buzzwords
2013 06-03 berlin buzzwords
 
My site is slow
My site is slowMy site is slow
My site is slow
 
Hard Coding as a design approach
Hard Coding as a design approachHard Coding as a design approach
Hard Coding as a design approach
 
Redis + Apache Spark = Swiss Army Knife Meets Kitchen Sink
Redis + Apache Spark = Swiss Army Knife Meets Kitchen SinkRedis + Apache Spark = Swiss Army Knife Meets Kitchen Sink
Redis + Apache Spark = Swiss Army Knife Meets Kitchen Sink
 
Building Efficient and Reliable Crawler System With Sidekiq Enterprise
Building Efficient and Reliable Crawler System With Sidekiq EnterpriseBuilding Efficient and Reliable Crawler System With Sidekiq Enterprise
Building Efficient and Reliable Crawler System With Sidekiq Enterprise
 
Rails performance at Justin.tv - Guillaume Luccisano
Rails performance at Justin.tv - Guillaume LuccisanoRails performance at Justin.tv - Guillaume Luccisano
Rails performance at Justin.tv - Guillaume Luccisano
 
Modern Web technologies (and why you should care): Megacomm, Jerusalem, Febru...
Modern Web technologies (and why you should care): Megacomm, Jerusalem, Febru...Modern Web technologies (and why you should care): Megacomm, Jerusalem, Febru...
Modern Web technologies (and why you should care): Megacomm, Jerusalem, Febru...
 
BTV PHP - Building Fast Websites
BTV PHP - Building Fast WebsitesBTV PHP - Building Fast Websites
BTV PHP - Building Fast Websites
 
Ruby's Concurrency Management: Now and Future
Ruby's Concurrency Management: Now and FutureRuby's Concurrency Management: Now and Future
Ruby's Concurrency Management: Now and Future
 
Fault Tolerance in Distributed Environment
Fault Tolerance in Distributed EnvironmentFault Tolerance in Distributed Environment
Fault Tolerance in Distributed Environment
 
Celery: The Distributed Task Queue
Celery: The Distributed Task QueueCelery: The Distributed Task Queue
Celery: The Distributed Task Queue
 
Modern Web Technologies — Jerusalem Web Professionals, January 2011
Modern Web Technologies — Jerusalem Web Professionals, January 2011Modern Web Technologies — Jerusalem Web Professionals, January 2011
Modern Web Technologies — Jerusalem Web Professionals, January 2011
 
How we migrated Zalando app to Swift3?
How we migrated Zalando app to Swift3?How we migrated Zalando app to Swift3?
How we migrated Zalando app to Swift3?
 

Último

Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 

Último (20)

Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 

Asynchronous Awesome

Notas do Editor

  1. Okay, my talk is called &amp;#x201C;...&amp;#x201D; which I think is pretty descriptive. Except that it doesn&amp;#x2019;t really demonstrate the pure awesome is that is Resque, so really, we&amp;#x2019;ll call it...
  2. Yeah.
  3. So, why should you care about what I&amp;#x2019;m going to say in the next 20 minutes? Because when you walk away from this room, you&amp;#x2019;ll all be experts at building a network of high-performance and fault-tolerant workers.
  4. So we&amp;#x2019;re going to talk about three things today
  5. First, we&amp;#x2019;re going to do a general background of background processing
  6. Next, we&amp;#x2019;ll cover the basic concepts of Resque that are derived from Delayed::Job
  7. Last, we&amp;#x2019;ll get into Resque, and how it&amp;#x2019;s different.
  8. So, why run background tasks at all?
  9. - Resize - Etc That&amp;#x2019;s all really cool stuff, but it all takes time - sometimes a few seconds, sometimes up to 30 seconds. So, someone, somewhere, had an idea:
  10. - Resize - Etc That&amp;#x2019;s all really cool stuff, but it all takes time - sometimes a few seconds, sometimes up to 30 seconds. So, someone, somewhere, had an idea:
  11. - Resize - Etc That&amp;#x2019;s all really cool stuff, but it all takes time - sometimes a few seconds, sometimes up to 30 seconds. So, someone, somewhere, had an idea:
  12. - Resize - Etc That&amp;#x2019;s all really cool stuff, but it all takes time - sometimes a few seconds, sometimes up to 30 seconds. So, someone, somewhere, had an idea:
  13. Let&amp;#x2019;s do something later than now. If my application doesn&amp;#x2019;t NEED to do this stuff right away, don&amp;#x2019;t keep the request tied up. After all, what IS a request for?
  14. Webpages In case you&amp;#x2019;d forgotten - Rails serves webpages. It&amp;#x2019;s not built to process images or send out mass e-mails; it&amp;#x2019;s built to do two things:
  15. Webpages In case you&amp;#x2019;d forgotten - Rails serves webpages. It&amp;#x2019;s not built to process images or send out mass e-mails; it&amp;#x2019;s built to do two things:
  16. Webpages In case you&amp;#x2019;d forgotten - Rails serves webpages. It&amp;#x2019;s not built to process images or send out mass e-mails; it&amp;#x2019;s built to do two things:
  17. Webpages In case you&amp;#x2019;d forgotten - Rails serves webpages. It&amp;#x2019;s not built to process images or send out mass e-mails; it&amp;#x2019;s built to do two things:
  18. - Receive requests - Send responses
  19. - Receive requests - Send responses
  20. Everything else can go elsewhere
  21. So... where should it go? There are a whole bunch of options. - CRON - Etc. But sometimes those setups have problems
  22. So... where should it go? There are a whole bunch of options. - CRON - Etc. But sometimes those setups have problems
  23. So... where should it go? There are a whole bunch of options. - CRON - Etc. But sometimes those setups have problems
  24. So... where should it go? There are a whole bunch of options. - CRON - Etc. But sometimes those setups have problems
  25. - They can fail without telling you why - You can&amp;#x2019;t get the status of one of a worker - Ruby processes can be unstable and crash-ey So maybe you need something a little bit better
  26. - They can fail without telling you why - You can&amp;#x2019;t get the status of one of a worker - Ruby processes can be unstable and crash-ey So maybe you need something a little bit better
  27. - They can fail without telling you why - You can&amp;#x2019;t get the status of one of a worker - Ruby processes can be unstable and crash-ey So maybe you need something a little bit better
  28. Delayed::Job to the rescue!
  29. A Delayed::Job is an ActiveRecord model, so it lives in the database. - You get persistence baked right in - It&amp;#x2019;s unbelievably easy to use
  30. A Delayed::Job is an ActiveRecord model, so it lives in the database. - You get persistence baked right in - It&amp;#x2019;s unbelievably easy to use
  31. How easy?
  32. Super easy. I pulled this straight from the github page. This code shows how you would create a Delayed::Job
  33. But where does that job go?
  34. Here - your database. Notice that it simply marshals the object and stuffs in the database.
  35. So what do you do with these jobs in the database? - Run the delayed_job script This will create...
  36. Workers. They&amp;#x2019;re separate Ruby processes that - Live in their own thread - Find jobs in the database - Perform them separately from the request/response cycle They boot up your Rails environment to do so.
  37. Workers. They&amp;#x2019;re separate Ruby processes that - Live in their own thread - Find jobs in the database - Perform them separately from the request/response cycle They boot up your Rails environment to do so.
  38. Workers. They&amp;#x2019;re separate Ruby processes that - Live in their own thread - Find jobs in the database - Perform them separately from the request/response cycle They boot up your Rails environment to do so.
  39. So before, you had requests coming from a browser into Rails, which dispatches to various services, gets results, and sends something back to the browser
  40. Now you have Rails storing the jobs for later, and Delayed::Job comes along and does the processing Rails isn&amp;#x2019;t good at doing anyway.
  41. So Delayed::Job is totally rad. It handles most of what you might want it to handle.
  42. So when we start in with Resque, you might wonder, &amp;#x201C;Isn&amp;#x2019;t Delayed::Job enough?&amp;#x201D;
  43. Apparently not. There are some situations where Delayed::Job isn&amp;#x2019;t sufficient.
  44. Basically, Resque is enterprise grade shit.
  45. So the first big difference between Resque and Delayed::Job is that Resque doesn&amp;#x2019;t rely on ActiveRecord. It runs on something called Redis, which probably deserves - its own tangent
  46. Redis is an in-memory Key-Value Store similar to Memcached. But it offers
  47. Redis is an in-memory Key-Value Store similar to Memcached. But it offers
  48. Redis is an in-memory Key-Value Store similar to Memcached. But it offers
  49. Redis is an in-memory Key-Value Store similar to Memcached. But it offers
  50. Redis is an in-memory Key-Value Store similar to Memcached. But it offers
  51. Redis is an in-memory Key-Value Store similar to Memcached. But it offers
  52. Persistence! So you can reboot your server and Redis will reload your original queued jobs. It also is great at
  53. Scalability! The Ruby gem will load-balance tasks across multiple Redis servers for you, meaning you spend less time configuring and more time queueing
  54. So Redis makes Resque incredibly fast and easily distributed.
  55. Also, using Redis means you don&amp;#x2019;t have to worry about ActiveRecord - so you can skip Rails entirely
  56. The next big difference is Resque&amp;#x2019;s workers - When a worker finds a job to process, it creates a fork that it can monitor to process the job If a fork spirals out, it doesn&amp;#x2019;t take the worker with it - Workers are capable of moving failed jobs into the failed List and moving on with their lives - Workers are also capable of timing their own processes out and failing them
  57. The next big difference is Resque&amp;#x2019;s workers - When a worker finds a job to process, it creates a fork that it can monitor to process the job If a fork spirals out, it doesn&amp;#x2019;t take the worker with it - Workers are capable of moving failed jobs into the failed List and moving on with their lives - Workers are also capable of timing their own processes out and failing them
  58. The next big difference is Resque&amp;#x2019;s workers - When a worker finds a job to process, it creates a fork that it can monitor to process the job If a fork spirals out, it doesn&amp;#x2019;t take the worker with it - Workers are capable of moving failed jobs into the failed List and moving on with their lives - Workers are also capable of timing their own processes out and failing them
  59. Resque also supports queues, so different types of tasks can be divided by disparate workers. A file server, for example, can have a worker that only zips files - while a web server can warm image caches.
  60. Resque also skips the marshaling step, and instead opts for a class and a JSON-ifiable argument list. This will keep all instances current
  61. The class&amp;#x2019; &amp;#x201C;perform&amp;#x201D; method is called with the arguments you enqueued it with
  62. Resque comes with its own interface for monitoring queues and tasks, and reviewing failed tasks.
  63. So why use Resque? Use Resque if - You have many, many, many background tasks - You need to have different servers performing different types tasks - You need bullet-proof workers
  64. So why use Resque? Use Resque if - You have many, many, many background tasks - You need to have different servers performing different types tasks - You need bullet-proof workers
  65. So why use Resque? Use Resque if - You have many, many, many background tasks - You need to have different servers performing different types tasks - You need bullet-proof workers
  66. Trouble - Complex / expensive - No scheduling or priority - Asynchronous Redis writes don&amp;#x2019;t guarantee persistence
  67. Trouble - Complex / expensive - No scheduling or priority - Asynchronous Redis writes don&amp;#x2019;t guarantee persistence
  68. Trouble - Complex / expensive - No scheduling or priority - Asynchronous Redis writes don&amp;#x2019;t guarantee persistence
  69. Okay, if we have time I&amp;#x2019;ll show off Resque&amp;#x2019;s UI and do a quick comparison of it to D::J
  70. Thanks for listening!
  71. This is me - you can find me on Github or Twitter, and if you&amp;#x2019;re interested I&amp;#x2019;ll post these slides on Twitter.
  72. Last but not least, I&amp;#x2019;m a visiting emissary from B&amp;#x2019;more on Rails, and I&amp;#x2019;d like to personally invite all of you to come up to our Meetups (on the 2nd tuesday of every month) and our Open Source Hack Nights (on the 4th Tuesday of every month).