SlideShare a Scribd company logo
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/

More Related Content

What's hot

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 Overview
jonkinney
 
Ember & WebComponents
Ember & WebComponentsEmber & WebComponents
Ember & WebComponents
Alex LaFroscia
 
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 buzzwords
Jared Faris
 
Avoiding Common Pitfalls in Ember.js
Avoiding Common Pitfalls in Ember.jsAvoiding Common Pitfalls in Ember.js
Avoiding Common Pitfalls in Ember.js
Alex Speller
 
Kevin Whinnery: Write Better JavaScript
Kevin Whinnery: Write Better JavaScriptKevin Whinnery: Write Better JavaScript
Kevin Whinnery: Write Better JavaScript
Axway Appcelerator
 
Untangling spring week9
Untangling spring week9Untangling spring week9
Untangling spring week9
Derek 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 Complexity
Augustin Riedinger
 
Untangling spring week10
Untangling spring week10Untangling spring week10
Untangling spring week10
Derek Jacoby
 

What's hot (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
 

Viewers also liked

Open Source 2.0
Open Source 2.0Open Source 2.0
Open Source 2.0
samof76
 
In the Back of Your Mind
In the Back of Your MindIn the Back of Your Mind
In the Back of Your Mind
James Gray
 
Supervisord, The Process Manager
Supervisord, The Process ManagerSupervisord, The Process Manager
Supervisord, The Process Manager
samof76
 
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 queue
Mike 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 2011
Mike Willbanks
 

Viewers also liked (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
 

Similar to Asynchronous Awesome

Lessons Learnt in 2009
Lessons Learnt in 2009Lessons Learnt in 2009
Lessons Learnt in 2009
pratiknaik
 
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 2013
hernanibf
 
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 Cloud
Tony 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 slow
hernanibf
 
Hard Coding as a design approach
Hard Coding as a design approachHard Coding as a design approach
Hard Coding as a design approach
Oren 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 Sink
Databricks
 
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
Gary 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 Luccisano
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...
Reuven Lerner
 
BTV PHP - Building Fast Websites
BTV PHP - Building Fast WebsitesBTV PHP - Building Fast Websites
BTV PHP - Building Fast Websites
Jonathan 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 Future
Koichi Sasada
 
Fault Tolerance in Distributed Environment
Fault Tolerance in Distributed EnvironmentFault Tolerance in Distributed Environment
Fault Tolerance in Distributed Environment
Orkhan Gasimov
 
Celery: The Distributed Task Queue
Celery: The Distributed Task QueueCelery: The Distributed Task Queue
Celery: The Distributed Task Queue
Richard 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 2011
Reuven 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
 

Similar to 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?
 

Recently uploaded

Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Enhancing Performance with Globus and the Science DMZ
Enhancing Performance with Globus and the Science DMZEnhancing Performance with Globus and the Science DMZ
Enhancing Performance with Globus and the Science DMZ
Globus
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..
UiPathCommunity
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Pierluigi Pugliese
 

Recently uploaded (20)

Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Enhancing Performance with Globus and the Science DMZ
Enhancing Performance with Globus and the Science DMZEnhancing Performance with Globus and the Science DMZ
Enhancing Performance with Globus and the Science DMZ
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
 

Asynchronous Awesome

Editor's Notes

  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).