Queue Everything
       &
Please Everyone
       ***

   Vaidik Kapoor
Who am I?
➔   Undergraduate student.
➔   Involved with:
    ✔   Mozilla as a Contributor and Rep
    ✔   Drupal as a Contributor
➔   Twitter: @vaidikkapoor
➔   Github: vaidikkp
➔   Web: vaidikkapoor.info
Web Applications
Responsiveness
Request                      Response
                      Client




    Task 1   Task 2   Task 3   Task N




Why do everything at once?
Break the Request-Response Cycle
       Request                   Response
                      Client




           Task 1              Task N




                    Task 2




                    Task 3
Meet Queues
What can Queues help with?
➔   Background Processing
    ✔   Data Processing
    ✔   Media Processing
    ✔   Updating Caches
➔   Anything that you want to offload off your
    server.
➔   Improve the overall User Experience
Redis
       +
HotQueue / PyRes
Redis + HotQueue
PRODUCER:

from hotqueue import HotQueue
queue = HotQueue("myqueue", host="localhost", port=6379, db=0)

queue.put(message)




CONSUMER / WORKER:

from hotqueue import HotQueue
queue = HotQueue("myqueue", host="localhost", port=6379, db=0)

while True:
     message = queue.get()
     # do something awesome
Redis + PyRes
➔   Python clone of Github's Resque
➔   Offers a lot more features than HotQueue
    ✔   Job failure handling
    ✔   Queue status information
➔   Comes with Monitoring System written in Ruby
Redis + PyRes
PRODUCER:

from pyres import ResQ
r = Resq()

class WebPage:
     queue = “screenies”

    @staticmethod
    def perform(urll):
         # save the screenshot

r.enqueue(WebPage, 'http://python.org')


CONSUMER:

./pyres_worker screenies
Message Queue
A system for enabling asynchronous processing
               of discrete tasks.
What can MQs help with?
➔   Everything that generic Queues can help with.
➔   Increase Reliability
➔   Cron Jobs (Celery)
Available MQ Solutions
➔   RabbitMQ
➔   Amazon Simple Queue
➔   Apache MQ
➔   Gearman
➔   Starling
➔   OpenAMQ
➔   Sun Java Message Queue System
Message Queue Protocols
➔   AMQP: Advanced Message Queue Protocol
➔   JMS: Java Messaging Service
➔   STOMP: Streaming Text Oriented Messaging
    Protocol
Criteria for Broker Selection
➔   Difficulty in Recovery
➔   Relatively low level of required maintenance
➔   Ease of Deployment
➔   Durability
➔   Persistence
➔   Community Support
➔   Cluster Support
➔   What language is it written in?
RabbitMQ
➔   A Message Broker
➔   Implements AMQP
Pika & Other AMQP Libraries
Celery
➔   An amazing Task Manager
➔   Batteries Included
➔   Uses RabbitMQ as broker (or almost anything)
➔   Libraries for most of the common web frameworks
    like Django, Flask, Pyramid
➔   Supports multiprocessing.
➔   Distribute tasks easily.
➔   Makes life easy
Celery Example
from celery.task import task

@task():
def take_screenshot(url):
  # magical code to take screenshot comes here
How to put it all together?
The General Setup

                   Task
Web App                        Broker
                  Manager




                  Worker
Database         Server (s)
Then what?
Notify Your Users
Django's Messaging System
Flask's Flashes
Poll using AJAX
WebSockets
Email
Things to Remember
Isolate
Isolate code, make reusable components.
Recycle
Remove Request Dependency
Unit Testing?
Review
➔   Choose a system according to needs
➔   Build a robust system
➔   Integrate seamlessly with your UI
➔   Isolate & Recycle: make it a habit
➔   Improve the overall UX!
➔   Please everyone, even yourself!
References
➔   PyRes - http://pyres.readthedocs.org/
➔   RabbitMQ - http://www.rabbitmq.com/
➔   Celery - http://celeryproject.org/
➔   Amazing Article -
    http://wiki.secondlife.com/wiki/Message_Queue_Evaluation_Notes
Thank You!

More Related Content

ODP
Version Controlling
PDF
Understanding Non Blocking I/O with Python
PDF
Vagrant for Effective DevOps Culture
PDF
Nodejs
PDF
Andrea Di Persio
PDF
Hacking on WildFly 9
PDF
Introduction to node js - From "hello world" to deploying on azure
PPTX
Gestire i rilasci automatici con azure devops
Version Controlling
Understanding Non Blocking I/O with Python
Vagrant for Effective DevOps Culture
Nodejs
Andrea Di Persio
Hacking on WildFly 9
Introduction to node js - From "hello world" to deploying on azure
Gestire i rilasci automatici con azure devops

What's hot (20)

PPTX
Infrastructure development on windows ldn cd meetup
PDF
Serverless framework와 CircleCI를 통한 NoOps 맛보기
PPTX
Short-Training asp.net vNext
PDF
Node4J: Running Node.js in a JavaWorld
PDF
VMUG St Louis - SDN in the Real World
PDF
Webconf nodejs-production-architecture
PPTX
Level Up: 5 Expert Tips for Optimizing WordPress Performance
PPTX
Silverstripe at scale - design & architecture for silverstripe applications
PDF
Webinar - Matteo Manchi: Dal web al nativo: Introduzione a React Native
PPTX
NGINX for Application Delivery & Acceleration
PPTX
Grafana and MySQL - Benefits and Challenges
PDF
CFWheels - Pragmatic, Beautiful Code
PDF
Case study: JBoss Developer Studio, an IDE for Web, Mobile and Cloud applicat...
PDF
Mobile Library Development - stuck between a pod and a jar file - Zan Markan ...
PDF
Altitude San Francisco 2018: HTTP Invalidation Workshop
PPTX
Docker, From zero to hero
PDF
Hacking on WildFly 9
PDF
Mini-Training: Redis
PPTX
Get acquainted with the new ASP.Net 5
PPTX
Glass fish performance tuning tips from the field
Infrastructure development on windows ldn cd meetup
Serverless framework와 CircleCI를 통한 NoOps 맛보기
Short-Training asp.net vNext
Node4J: Running Node.js in a JavaWorld
VMUG St Louis - SDN in the Real World
Webconf nodejs-production-architecture
Level Up: 5 Expert Tips for Optimizing WordPress Performance
Silverstripe at scale - design & architecture for silverstripe applications
Webinar - Matteo Manchi: Dal web al nativo: Introduzione a React Native
NGINX for Application Delivery & Acceleration
Grafana and MySQL - Benefits and Challenges
CFWheels - Pragmatic, Beautiful Code
Case study: JBoss Developer Studio, an IDE for Web, Mobile and Cloud applicat...
Mobile Library Development - stuck between a pod and a jar file - Zan Markan ...
Altitude San Francisco 2018: HTTP Invalidation Workshop
Docker, From zero to hero
Hacking on WildFly 9
Mini-Training: Redis
Get acquainted with the new ASP.Net 5
Glass fish performance tuning tips from the field
Ad

Viewers also liked (18)

PDF
12 tips on Django Best Practices
PDF
Open Networking Foundation, Year 3: Don’t bother trying to catch your breath
PPTX
Celery workshop
KEY
Django Celery
PPTX
Celery in the Django
PDF
Website Monitoring with Distributed Messages/Tasks Processing (AMQP & RabbitM...
ODP
Introduction to Python Celery
PDF
Building Distributed System with Celery on Docker Swarm
PDF
Advanced task management with Celery
PDF
Celery by dummy
PDF
Scaling up task processing with Celery
PDF
Life in a Queue - Using Message Queue with django
PDF
Practical Celery
PDF
Resftul API Web Development with Django Rest Framework & Celery
PDF
Building Distributed System with Celery on Docker Swarm - PyCon JP 2016
PDF
Distributed Task Processing with Celery - PyZH
PDF
An Introduction to Celery
ODP
Europython 2011 - Playing tasks with Django & Celery
12 tips on Django Best Practices
Open Networking Foundation, Year 3: Don’t bother trying to catch your breath
Celery workshop
Django Celery
Celery in the Django
Website Monitoring with Distributed Messages/Tasks Processing (AMQP & RabbitM...
Introduction to Python Celery
Building Distributed System with Celery on Docker Swarm
Advanced task management with Celery
Celery by dummy
Scaling up task processing with Celery
Life in a Queue - Using Message Queue with django
Practical Celery
Resftul API Web Development with Django Rest Framework & Celery
Building Distributed System with Celery on Docker Swarm - PyCon JP 2016
Distributed Task Processing with Celery - PyZH
An Introduction to Celery
Europython 2011 - Playing tasks with Django & Celery
Ad

Similar to Queue Everything and Please Everyone (20)

PDF
Comment améliorer le quotidien des Développeurs PHP ?
PDF
CNCF_ A step to step guide to platforming your delivery setup.pdf
PDF
Rock Solid Deployment of Web Applications
PDF
Edge Side APIs: Fast and Reliable Hypermedia APIs
PDF
Kubecon seattle 2018 workshop slides
PDF
DevOpsDays Warsaw 2015: Automating microservices in Syncano – Michał Kobus & ...
PPTX
What's New in Docker - February 2017
PDF
Introducing DevSecOps by Madhu Akula - Software Security Bangalore - May 27 2...
PPTX
Docker & Daily DevOps
PPTX
Docker and-daily-devops
PPTX
Planning to Fail #phpne13
PDF
ProxySQL Tutorial - PLAM 2016
ODP
Docker in prod
PDF
apidays LIVE Paris 2021 - Edge Side APIs by Kevin Dunglas, Les Tilleuls
PDF
Using Puppet - Real World Configuration Management
PDF
Docker and the Container Revolution
PDF
Writing your First Ansible Playbook
PPTX
Ranger admin dev overview
PDF
Porting Rails Apps to High Availability Systems
PDF
Playwright Testing Guide for QA Engineers.pdf
Comment améliorer le quotidien des Développeurs PHP ?
CNCF_ A step to step guide to platforming your delivery setup.pdf
Rock Solid Deployment of Web Applications
Edge Side APIs: Fast and Reliable Hypermedia APIs
Kubecon seattle 2018 workshop slides
DevOpsDays Warsaw 2015: Automating microservices in Syncano – Michał Kobus & ...
What's New in Docker - February 2017
Introducing DevSecOps by Madhu Akula - Software Security Bangalore - May 27 2...
Docker & Daily DevOps
Docker and-daily-devops
Planning to Fail #phpne13
ProxySQL Tutorial - PLAM 2016
Docker in prod
apidays LIVE Paris 2021 - Edge Side APIs by Kevin Dunglas, Les Tilleuls
Using Puppet - Real World Configuration Management
Docker and the Container Revolution
Writing your First Ansible Playbook
Ranger admin dev overview
Porting Rails Apps to High Availability Systems
Playwright Testing Guide for QA Engineers.pdf

Queue Everything and Please Everyone

  • 1. Queue Everything & Please Everyone *** Vaidik Kapoor
  • 2. Who am I? ➔ Undergraduate student. ➔ Involved with: ✔ Mozilla as a Contributor and Rep ✔ Drupal as a Contributor ➔ Twitter: @vaidikkapoor ➔ Github: vaidikkp ➔ Web: vaidikkapoor.info
  • 5. Request Response Client Task 1 Task 2 Task 3 Task N Why do everything at once?
  • 6. Break the Request-Response Cycle Request Response Client Task 1 Task N Task 2 Task 3
  • 8. What can Queues help with? ➔ Background Processing ✔ Data Processing ✔ Media Processing ✔ Updating Caches ➔ Anything that you want to offload off your server. ➔ Improve the overall User Experience
  • 9. Redis + HotQueue / PyRes
  • 10. Redis + HotQueue PRODUCER: from hotqueue import HotQueue queue = HotQueue("myqueue", host="localhost", port=6379, db=0) queue.put(message) CONSUMER / WORKER: from hotqueue import HotQueue queue = HotQueue("myqueue", host="localhost", port=6379, db=0) while True: message = queue.get() # do something awesome
  • 11. Redis + PyRes ➔ Python clone of Github's Resque ➔ Offers a lot more features than HotQueue ✔ Job failure handling ✔ Queue status information ➔ Comes with Monitoring System written in Ruby
  • 12. Redis + PyRes PRODUCER: from pyres import ResQ r = Resq() class WebPage: queue = “screenies” @staticmethod def perform(urll): # save the screenshot r.enqueue(WebPage, 'http://python.org') CONSUMER: ./pyres_worker screenies
  • 13. Message Queue A system for enabling asynchronous processing of discrete tasks.
  • 14. What can MQs help with? ➔ Everything that generic Queues can help with. ➔ Increase Reliability ➔ Cron Jobs (Celery)
  • 15. Available MQ Solutions ➔ RabbitMQ ➔ Amazon Simple Queue ➔ Apache MQ ➔ Gearman ➔ Starling ➔ OpenAMQ ➔ Sun Java Message Queue System
  • 16. Message Queue Protocols ➔ AMQP: Advanced Message Queue Protocol ➔ JMS: Java Messaging Service ➔ STOMP: Streaming Text Oriented Messaging Protocol
  • 17. Criteria for Broker Selection ➔ Difficulty in Recovery ➔ Relatively low level of required maintenance ➔ Ease of Deployment ➔ Durability ➔ Persistence ➔ Community Support ➔ Cluster Support ➔ What language is it written in?
  • 18. RabbitMQ ➔ A Message Broker ➔ Implements AMQP
  • 19. Pika & Other AMQP Libraries
  • 20. Celery ➔ An amazing Task Manager ➔ Batteries Included ➔ Uses RabbitMQ as broker (or almost anything) ➔ Libraries for most of the common web frameworks like Django, Flask, Pyramid ➔ Supports multiprocessing. ➔ Distribute tasks easily. ➔ Makes life easy
  • 21. Celery Example from celery.task import task @task(): def take_screenshot(url): # magical code to take screenshot comes here
  • 22. How to put it all together?
  • 23. The General Setup Task Web App Broker Manager Worker Database Server (s)
  • 30. Email
  • 32. Isolate Isolate code, make reusable components.
  • 35. Review ➔ Choose a system according to needs ➔ Build a robust system ➔ Integrate seamlessly with your UI ➔ Isolate & Recycle: make it a habit ➔ Improve the overall UX! ➔ Please everyone, even yourself!
  • 36. References ➔ PyRes - http://pyres.readthedocs.org/ ➔ RabbitMQ - http://www.rabbitmq.com/ ➔ Celery - http://celeryproject.org/ ➔ Amazing Article - http://wiki.secondlife.com/wiki/Message_Queue_Evaluation_Notes