SlideShare una empresa de Scribd logo
1 de 28
Massaging the Pony:Message Queues and You Shawn Rider PBS Education DjangoCon 2010 http://www.flickr.com/photos/funtik/1175522045
What is a Message Queue? A system for enabling asynchronous processing of discrete tasks. Super awesome. http://www.flickr.com/photos/gadl/89650415
What are they good for? Alleviate server issues by offloading processing http://www.flickr.com/photos/islandgyrl/3197469932
What are they good for? Make better user experiences http://www.flickr.com/photos/bbaltimore/6779682
What are they good for? Increase the reliability of third party service integrations.
What are they good for? Background media processing http://www.flickr.com/photos/factoryjoe/2882992091
What are they good for?  Repeating Tasks can replace Cron jobs   Keep all your code in your project
Available MQ Solutions There are many solutions out there. To name a few of them: RabbitMQ Amazon Simple Queue System Apache MQ Gearman OpenAMQ Peafowl Q4M Starling Sun Java System Message Queue
Message Queue Protocols AMQP: Advanced Message Queuing Protocol JMS: Java Messaging Service STOMP: Streaming Text Oriented Messaging Protocol
Criteria for Broker Selection The following criteria were important to us in selecting a solution. You may have some different needs. Handling exceptions and recovery Low level of required maintenance Ease of deployment Persistent queuing Community support What language is it written in? How compatible is that with our current systems? Cluster support
Failsafe MQ Brokers Must be able to survive a server failure. Upon restarting the MQ Broker, processing should resume from the last un-processed messages in queues
Queue Durability The Messages Queue Broker must be able to reconstruct the queues when it is restarted. http://www.flickr.com/photos/raul/846318014
Message Persistence The Messages (tasks to be completed) must persist between shutdowns and restarts of MQ Server
Our Choice Celery (a Django task management app) Carrot (Django middleware) PyAMQP (Python module) RabbitMQ (MQ Broker software)
The Production System Webapp Rabbit MQ Celery Worker Server(s) Database
MQ in Development Environs It is important to be able to develop Message Queue tasks in Django without being concerned about running the broker process, queue setup, persistence etc.
MQ in Development Environs CARROT_BACKEND = ‘qhettoq.taproot.Database’ Carrot can be set up to use different queuing backend for development purposes GhettoQ provides database backend for carrot where a database serves as the queue storage The broker is a simple Django application that monitors the queue in DB Inefficient, therefore only suitable for development environments
Ease a future MQ implementation Isolate functionality into reusable components.
Recycle Existing Code
Django, HTTP Requests & MQ Most functionalities provided throughDjangoapplications are tightly coupled with HTTP requests e.g. form data processing In order to asynchronously execute a task, Celery (any task management platform) must serialize & store parameters HTTP requests are usually large and not easily serializable. e.g. WSGI requests
ThePickleableHTTPRequestObject
UsingPickleableHttpRequest if request.GET.get(‘download’): try:         result = EnrollmentCSVExportTask.delay( PickleableHttpRequest(                 request,                  attributes=br />                [‘user’, ‘admin_current_organization’]             )         )
Making Message Queue Tasks It is fast and easy to add a decorator to specific functions to create Message Queue tasks. from celery.decoratorsimport task @task def add(x, y): return x + y
Explicitly Inherit from Celery’s Task Object
Then What? Some Message Queue tasks can complete with no notification required. For other tasks: Notify by email Use an AJAX listener to notify users Some other messaging
In Review Choose your MQ solution wisely Set up a robust system Leverage your existing code Replace trouble spots as they come up Profit!
Message Queues Make Life Better
References and Links Second Life’s Survey of Message Queues:http://wiki.secondlife.com/wiki/Message_Queue_Evaluation_Notes Ask SolemHoel’sGithub Repos:  http://github.com/ask Celery Project: http://celeryproject.org/ PickleableHttpRequest by NowellStrite (@nowells) http://gist.github.com/571027 Special thanks to TarequeHossain (http://codexn.com)

Más contenido relacionado

La actualidad más candente

Hands On, Duchess 10/17/2012
Hands On, Duchess 10/17/2012Hands On, Duchess 10/17/2012
Hands On, Duchess 10/17/2012
slandelle
 
Gatling Tool in Action at Devoxx 2012
Gatling Tool in Action at Devoxx 2012Gatling Tool in Action at Devoxx 2012
Gatling Tool in Action at Devoxx 2012
slandelle
 

La actualidad más candente (17)

Accessing Mule variables in groovy
Accessing Mule variables in groovyAccessing Mule variables in groovy
Accessing Mule variables in groovy
 
Messaging with the Docker
Messaging with the DockerMessaging with the Docker
Messaging with the Docker
 
Introduction to Prometheus
Introduction to PrometheusIntroduction to Prometheus
Introduction to Prometheus
 
Servlet lifecycle
Servlet lifecycleServlet lifecycle
Servlet lifecycle
 
Java servlet technology
Java servlet technologyJava servlet technology
Java servlet technology
 
jLove 2020 - Micronaut and graalvm: The power of AoT
jLove 2020 - Micronaut and graalvm: The power of AoTjLove 2020 - Micronaut and graalvm: The power of AoT
jLove 2020 - Micronaut and graalvm: The power of AoT
 
Performance tests with gatling
Performance tests with gatlingPerformance tests with gatling
Performance tests with gatling
 
Javantura v3 - ES6 – Future Is Now – Nenad Pečanac
Javantura v3 - ES6 – Future Is Now – Nenad PečanacJavantura v3 - ES6 – Future Is Now – Nenad Pečanac
Javantura v3 - ES6 – Future Is Now – Nenad Pečanac
 
Hands On, Duchess 10/17/2012
Hands On, Duchess 10/17/2012Hands On, Duchess 10/17/2012
Hands On, Duchess 10/17/2012
 
Gatling Tool in Action at Devoxx 2012
Gatling Tool in Action at Devoxx 2012Gatling Tool in Action at Devoxx 2012
Gatling Tool in Action at Devoxx 2012
 
Migrating to java 9 modules
Migrating to java 9 modulesMigrating to java 9 modules
Migrating to java 9 modules
 
Celery introduction
Celery introductionCelery introduction
Celery introduction
 
Kafka monitoring and metrics
Kafka monitoring and metricsKafka monitoring and metrics
Kafka monitoring and metrics
 
java servlet and servlet programming
java servlet and servlet programmingjava servlet and servlet programming
java servlet and servlet programming
 
Why and how Pricing Assistant migrated from Celery to RQ - Paris.py #2
Why and how Pricing Assistant migrated from Celery to RQ - Paris.py #2Why and how Pricing Assistant migrated from Celery to RQ - Paris.py #2
Why and how Pricing Assistant migrated from Celery to RQ - Paris.py #2
 
Gatling
GatlingGatling
Gatling
 
Introduction to node.js
Introduction to node.jsIntroduction to node.js
Introduction to node.js
 

Similar a Massaging the Pony: Message Queues and You

Surekha_haoop_exp
Surekha_haoop_expSurekha_haoop_exp
Surekha_haoop_exp
surekhakadi
 
MY NEWEST RESUME
MY NEWEST RESUMEMY NEWEST RESUME
MY NEWEST RESUME
Han Yan
 
MY NEWEST RESUME
MY NEWEST RESUMEMY NEWEST RESUME
MY NEWEST RESUME
Han Yan
 
MY NEWEST RESUME
MY NEWEST RESUMEMY NEWEST RESUME
MY NEWEST RESUME
Han Yan
 
20211202 North America DevOps Group NADOG Adapting to Covid With Serverless C...
20211202 North America DevOps Group NADOG Adapting to Covid With Serverless C...20211202 North America DevOps Group NADOG Adapting to Covid With Serverless C...
20211202 North America DevOps Group NADOG Adapting to Covid With Serverless C...
Craeg Strong
 

Similar a Massaging the Pony: Message Queues and You (20)

Google App Engine for Java v0.0.2
Google App Engine for Java v0.0.2Google App Engine for Java v0.0.2
Google App Engine for Java v0.0.2
 
Open Source XMPP for Cloud Services
Open Source XMPP for Cloud ServicesOpen Source XMPP for Cloud Services
Open Source XMPP for Cloud Services
 
手把手教你如何串接 Log 到各種網路服務
手把手教你如何串接 Log 到各種網路服務手把手教你如何串接 Log 到各種網路服務
手把手教你如何串接 Log 到各種網路服務
 
Website Monitoring with Distributed Messages/Tasks Processing (AMQP & RabbitM...
Website Monitoring with Distributed Messages/Tasks Processing (AMQP & RabbitM...Website Monitoring with Distributed Messages/Tasks Processing (AMQP & RabbitM...
Website Monitoring with Distributed Messages/Tasks Processing (AMQP & RabbitM...
 
Surekha_haoop_exp
Surekha_haoop_expSurekha_haoop_exp
Surekha_haoop_exp
 
.net Framework
.net Framework.net Framework
.net Framework
 
Evolution of netflix conductor
Evolution of netflix conductorEvolution of netflix conductor
Evolution of netflix conductor
 
MY NEWEST RESUME
MY NEWEST RESUMEMY NEWEST RESUME
MY NEWEST RESUME
 
MY NEWEST RESUME
MY NEWEST RESUMEMY NEWEST RESUME
MY NEWEST RESUME
 
How and why we evolved a legacy Java web application to Scala... and we are s...
How and why we evolved a legacy Java web application to Scala... and we are s...How and why we evolved a legacy Java web application to Scala... and we are s...
How and why we evolved a legacy Java web application to Scala... and we are s...
 
jRecruiter - The AJUG Job Posting Service
jRecruiter - The AJUG Job Posting ServicejRecruiter - The AJUG Job Posting Service
jRecruiter - The AJUG Job Posting Service
 
A Hitchhiker's Guide to Cloud Native Java EE
A Hitchhiker's Guide to Cloud Native Java EEA Hitchhiker's Guide to Cloud Native Java EE
A Hitchhiker's Guide to Cloud Native Java EE
 
A Hitchhiker's Guide to Cloud Native Java EE
A Hitchhiker's Guide to Cloud Native Java EEA Hitchhiker's Guide to Cloud Native Java EE
A Hitchhiker's Guide to Cloud Native Java EE
 
MY NEWEST RESUME
MY NEWEST RESUMEMY NEWEST RESUME
MY NEWEST RESUME
 
Stateful mock servers to the rescue on REST ecosystems
Stateful mock servers to the rescue on REST ecosystemsStateful mock servers to the rescue on REST ecosystems
Stateful mock servers to the rescue on REST ecosystems
 
Spring boot microservice metrics monitoring
Spring boot   microservice metrics monitoringSpring boot   microservice metrics monitoring
Spring boot microservice metrics monitoring
 
Spring Boot - Microservice Metrics Monitoring
Spring Boot - Microservice Metrics MonitoringSpring Boot - Microservice Metrics Monitoring
Spring Boot - Microservice Metrics Monitoring
 
20211202 North America DevOps Group NADOG Adapting to Covid With Serverless C...
20211202 North America DevOps Group NADOG Adapting to Covid With Serverless C...20211202 North America DevOps Group NADOG Adapting to Covid With Serverless C...
20211202 North America DevOps Group NADOG Adapting to Covid With Serverless C...
 
Empowering Magnolia for Enterprise Use Cases - Experience Report
Empowering Magnolia for Enterprise Use Cases - Experience ReportEmpowering Magnolia for Enterprise Use Cases - Experience Report
Empowering Magnolia for Enterprise Use Cases - Experience Report
 
Messaging - RabbitMQ, Azure (Service Bus), Docker and Azure Functions
Messaging - RabbitMQ, Azure (Service Bus), Docker and Azure FunctionsMessaging - RabbitMQ, Azure (Service Bus), Docker and Azure Functions
Messaging - RabbitMQ, Azure (Service Bus), Docker and Azure Functions
 

Más de Shawn Rider

Work is not a Dare: Tips for Building Inclusive Teams
Work is not a Dare: Tips for Building Inclusive TeamsWork is not a Dare: Tips for Building Inclusive Teams
Work is not a Dare: Tips for Building Inclusive Teams
Shawn Rider
 

Más de Shawn Rider (8)

Work is not a Dare: Tips for Building Inclusive Teams
Work is not a Dare: Tips for Building Inclusive TeamsWork is not a Dare: Tips for Building Inclusive Teams
Work is not a Dare: Tips for Building Inclusive Teams
 
Theming Sites with SASS
Theming Sites with SASSTheming Sites with SASS
Theming Sites with SASS
 
Living Syleguides
Living SyleguidesLiving Syleguides
Living Syleguides
 
Intro to Yo
Intro to YoIntro to Yo
Intro to Yo
 
Barbarians at the Gate: Games and Culture
Barbarians at the Gate: Games and CultureBarbarians at the Gate: Games and Culture
Barbarians at the Gate: Games and Culture
 
Django Forms: Best Practices, Tips, Tricks
Django Forms: Best Practices, Tips, TricksDjango Forms: Best Practices, Tips, Tricks
Django Forms: Best Practices, Tips, Tricks
 
Teaching an Old Pony New Tricks: Maintaining and Updating and Aging Django Site
Teaching an Old Pony New Tricks: Maintaining and Updating and Aging Django SiteTeaching an Old Pony New Tricks: Maintaining and Updating and Aging Django Site
Teaching an Old Pony New Tricks: Maintaining and Updating and Aging Django Site
 
How To Succeed In Web Design
How To Succeed In Web DesignHow To Succeed In Web Design
How To Succeed In Web Design
 

Último

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Último (20)

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
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
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
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
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 

Massaging the Pony: Message Queues and You

  • 1. Massaging the Pony:Message Queues and You Shawn Rider PBS Education DjangoCon 2010 http://www.flickr.com/photos/funtik/1175522045
  • 2. What is a Message Queue? A system for enabling asynchronous processing of discrete tasks. Super awesome. http://www.flickr.com/photos/gadl/89650415
  • 3. What are they good for? Alleviate server issues by offloading processing http://www.flickr.com/photos/islandgyrl/3197469932
  • 4. What are they good for? Make better user experiences http://www.flickr.com/photos/bbaltimore/6779682
  • 5. What are they good for? Increase the reliability of third party service integrations.
  • 6. What are they good for? Background media processing http://www.flickr.com/photos/factoryjoe/2882992091
  • 7. What are they good for? Repeating Tasks can replace Cron jobs Keep all your code in your project
  • 8. Available MQ Solutions There are many solutions out there. To name a few of them: RabbitMQ Amazon Simple Queue System Apache MQ Gearman OpenAMQ Peafowl Q4M Starling Sun Java System Message Queue
  • 9. Message Queue Protocols AMQP: Advanced Message Queuing Protocol JMS: Java Messaging Service STOMP: Streaming Text Oriented Messaging Protocol
  • 10. Criteria for Broker Selection The following criteria were important to us in selecting a solution. You may have some different needs. Handling exceptions and recovery Low level of required maintenance Ease of deployment Persistent queuing Community support What language is it written in? How compatible is that with our current systems? Cluster support
  • 11. Failsafe MQ Brokers Must be able to survive a server failure. Upon restarting the MQ Broker, processing should resume from the last un-processed messages in queues
  • 12. Queue Durability The Messages Queue Broker must be able to reconstruct the queues when it is restarted. http://www.flickr.com/photos/raul/846318014
  • 13. Message Persistence The Messages (tasks to be completed) must persist between shutdowns and restarts of MQ Server
  • 14. Our Choice Celery (a Django task management app) Carrot (Django middleware) PyAMQP (Python module) RabbitMQ (MQ Broker software)
  • 15. The Production System Webapp Rabbit MQ Celery Worker Server(s) Database
  • 16. MQ in Development Environs It is important to be able to develop Message Queue tasks in Django without being concerned about running the broker process, queue setup, persistence etc.
  • 17. MQ in Development Environs CARROT_BACKEND = ‘qhettoq.taproot.Database’ Carrot can be set up to use different queuing backend for development purposes GhettoQ provides database backend for carrot where a database serves as the queue storage The broker is a simple Django application that monitors the queue in DB Inefficient, therefore only suitable for development environments
  • 18. Ease a future MQ implementation Isolate functionality into reusable components.
  • 20. Django, HTTP Requests & MQ Most functionalities provided throughDjangoapplications are tightly coupled with HTTP requests e.g. form data processing In order to asynchronously execute a task, Celery (any task management platform) must serialize & store parameters HTTP requests are usually large and not easily serializable. e.g. WSGI requests
  • 22. UsingPickleableHttpRequest if request.GET.get(‘download’): try: result = EnrollmentCSVExportTask.delay( PickleableHttpRequest( request, attributes=br /> [‘user’, ‘admin_current_organization’] ) )
  • 23. Making Message Queue Tasks It is fast and easy to add a decorator to specific functions to create Message Queue tasks. from celery.decoratorsimport task @task def add(x, y): return x + y
  • 24. Explicitly Inherit from Celery’s Task Object
  • 25. Then What? Some Message Queue tasks can complete with no notification required. For other tasks: Notify by email Use an AJAX listener to notify users Some other messaging
  • 26. In Review Choose your MQ solution wisely Set up a robust system Leverage your existing code Replace trouble spots as they come up Profit!
  • 27. Message Queues Make Life Better
  • 28. References and Links Second Life’s Survey of Message Queues:http://wiki.secondlife.com/wiki/Message_Queue_Evaluation_Notes Ask SolemHoel’sGithub Repos: http://github.com/ask Celery Project: http://celeryproject.org/ PickleableHttpRequest by NowellStrite (@nowells) http://gist.github.com/571027 Special thanks to TarequeHossain (http://codexn.com)

Notas del editor

  1. Example from TL about bulk refunds and paypal.
  2. Cron jobs essentially pass control of your code to the operating system. Although the Cron job is a valuable tool, it’s not the only option.
  3. Because a Message Queue Broker is a separate system that your project interfaces with, you could feasibly use many different apps created in many different languages.
  4. Cluster support will be a priority for a lot of people, but it was not a priority for us. (Cluster support is the ability to have a cluster of MQ Brokers.)
  5. To achieve this, we consider two concepts (on next slides).
  6. This is what that looks like in production. Many of these components exist on dedicated servers and/or server clusters.
  7. Some people who are more familiar with Carrot and Celery might wonder why not use the “always eager” setting, which processes MQ tasks in real time. However, in our experience that setting does not provide the effect we are after, and it is frustrating to get timeouts on long-running processes in development.
  8. You want to replace trouble spots in your project as they come up. No need to rewrite your entire project right away.
  9. The MockHTTP object always serializes GET and POST data. It then saves any additional HTTPRequest attributes specified when it is called.