Evented applications with RabbitMQ and CakePHP

M
Evented Applications
with RabbitMQ , Python, and CakePHP
What the wibblefish?

All about offloading work, and doing things in
‘realtime’
Make applications that complete tasks in a
distributed/scalable fashion.
Doing work outside the request/response cycle
of a UI/API.
Work to offload

Noti cations (SMS, Email, Postal mail).
Logging.
Import & export.
Process image & video.
Reporting.
Webhooks.
Isn’t cron good enough?



Cron tabs are great with one server.
Cron doesn’t scale to multiple machines.
Cron doesn’t solve the whole problem space.
Problems with Cron


Isn’t suitable for ‘real-time’ results.
Requires a set schedule. You might spin up
processes that do nothing. Or you might not
have enough capacity.
Parallelizing is a pain.
Queues to the rescue!


Queues accept and dispatch events.
Events can contain almost anything*.
Events can be roughly equal to ‘jobs’.
A single event can trigger lots of downstream
work.
Architectural benefits

Separation of concerns.
Collection of mini/small applications.
No monolithic applications.
Decoupled, and easier to test.
Easy to scale. Busy service = more of them.
Queue technologies

RabbitMQ
ZeroMQ
SQS
Celery
Gearman
RabbitMQ

Written in Erlang.
Open source and Free.
Really Fast.
Socket protocol that is has cheap connections.
Data persists after a crash.
Queue basics



Producers create events.
Consumers eat messages, and do work.
messages == events.
Queue Basics



Producer
Queue Basics



Producer
Queue Basics



Producer                  Consumer
Queue Basics

                          Consumer



Producer                    Consumer
Queue Basics

                          Consumer



Producer                    Consumer



                          Consumer
Exchanges

Exchanges abstract queues from the producer.
Route messages to queues, that are bound by
routing keys.
Allows consumers to listen to speci c routing
keys.
Multiple consumers can listen to the same
events.
Exchanges



Producer
Exchanges



Producer
Exchanges
               page_view

                           Consumer



Producer
Exchanges
               page_view

                           Consumer



                  import    Consumer
Producer
Exchanges
                 page_view

                              Consumer



                     import    Consumer
Producer



                              Consumer
               error,
              page_view
Topic subscription


Consumers can also listen to topics. Which are
keys separated by dots.
e.g page_view.search, page_view.update
Consumer could listen to page_view.*
Producing



Can create messages with many tools.
PHP, python, node, ruby, etc.
Messages can contain any stringy data (JSON)
Data for messages


Only string-y things can be stored in messages.
JSON encoded data in message.
Key to value stored in Redis/Memcache.
Keep messages small. RabbitMQ performs
better with small messages.
Consuming


Use a daemon process.
Daemons in PHP can be done, but they kinda
suck.
Usually use sleep(2) or other workaround.
sleep(2) moves you away from ‘real time’.
Aw bugger..
Use a better tool


Other tools are much better for making
daemons.
 Python (pika, kombu, sparkplug)
 NodeJS (node-amqp)
 Ruby (carrot, ruby-amqp)
Managing mixed applications



Many ways to get it done.
Avoid duplicating code.
Thin daemons + worker processes.
Thin daemons


Python/node daemon accepts messages.
Delegate to PHP worker processes.
Keeps PHP’s fork + die work ow.
Re-use application code by calling shells.
Thin daemons



PHP
Thin daemons



PHP
Thin daemons

               Py


PHP
Thin daemons

               Py


PHP            Py
Thin daemons

               Py


PHP            Py


               Py
Thin daemons

               Py    PHP


PHP            Py


               Py
Thin daemons

               Py    PHP


PHP            Py    PHP


               Py
Thin daemons

               Py    PHP


PHP            Py    PHP


               Py    PHP
Demo Time
Overview



Use CakeLog to re events.
Use CakePHP shell’s for actual work.
Thin python daemon for processing messages.
Python + sparkplug



Python module for creating queue listeners.
Created by a developer at FreshBooks.
Ini con guration le de nes behaviour.
What we’ll try:



User events logged during application.
Log events to the database.
Insert code
Limitations of using shells


Daemon and shell processes have to be on the
same box.
This can be limiting as you scale, depends on
how you structure applications.
Solutions


Use HTTP.
Have thin daemons dispatch back to the front-
end application using HTTP.
Use Basic/Digest authentication.
Use checksums.
HTTP daemons



PHP
HTTP daemons



PHP
HTTP daemons



PHP            Py
HTTP daemons


                     Web


PHP            Py
HTTP daemons


                     Web


PHP            Py      Web
HTTP daemons


                     Web


PHP            Py      Web


                      Web
Thanks; Questions?
1 of 51

Recommended

Ch ch-changes cake php2 by
Ch ch-changes cake php2Ch ch-changes cake php2
Ch ch-changes cake php2markstory
2.3K views65 slides
CakePHP mistakes made by
CakePHP mistakes madeCakePHP mistakes made
CakePHP mistakes mademarkstory
2.8K views43 slides
Getting modern with logging via log4perl by
Getting modern with logging via log4perlGetting modern with logging via log4perl
Getting modern with logging via log4perlDean Hamstead
5.9K views38 slides
Getting big without getting fat, in perl by
Getting big without getting fat, in perlGetting big without getting fat, in perl
Getting big without getting fat, in perlDean Hamstead
5K views36 slides
Learning Puppet Chapter 1 by
Learning Puppet Chapter 1Learning Puppet Chapter 1
Learning Puppet Chapter 1Vishal Biyani
6K views15 slides
Xdebug by
XdebugXdebug
XdebugBryce Embry
286 views41 slides

More Related Content

What's hot

Cooking Perl with Chef: Real World Tutorial with Jitterbug by
Cooking Perl with Chef: Real World Tutorial with JitterbugCooking Perl with Chef: Real World Tutorial with Jitterbug
Cooking Perl with Chef: Real World Tutorial with JitterbugDavid Golden
5.2K views15 slides
Web Hooks by
Web HooksWeb Hooks
Web HooksJeff Lindsay
15K views54 slides
Master the New Core of Drupal 8 Now: with Symfony and Silex by
Master the New Core of Drupal 8 Now: with Symfony and SilexMaster the New Core of Drupal 8 Now: with Symfony and Silex
Master the New Core of Drupal 8 Now: with Symfony and SilexRyan Weaver
4.7K views88 slides
Don't RTFM, WTFM - Open Source Documentation - German Perl Workshop 2010 by
Don't RTFM, WTFM - Open Source Documentation - German Perl Workshop 2010Don't RTFM, WTFM - Open Source Documentation - German Perl Workshop 2010
Don't RTFM, WTFM - Open Source Documentation - German Perl Workshop 2010singingfish
497 views53 slides
PECL Picks - Extensions to make your life better by
PECL Picks - Extensions to make your life betterPECL Picks - Extensions to make your life better
PECL Picks - Extensions to make your life betterZendCon
4.1K views74 slides
How WebHooks Will Make Us All Programmers by
How WebHooks Will Make Us All ProgrammersHow WebHooks Will Make Us All Programmers
How WebHooks Will Make Us All ProgrammersJeff Lindsay
36.9K views120 slides

What's hot(20)

Cooking Perl with Chef: Real World Tutorial with Jitterbug by David Golden
Cooking Perl with Chef: Real World Tutorial with JitterbugCooking Perl with Chef: Real World Tutorial with Jitterbug
Cooking Perl with Chef: Real World Tutorial with Jitterbug
David Golden5.2K views
Master the New Core of Drupal 8 Now: with Symfony and Silex by Ryan Weaver
Master the New Core of Drupal 8 Now: with Symfony and SilexMaster the New Core of Drupal 8 Now: with Symfony and Silex
Master the New Core of Drupal 8 Now: with Symfony and Silex
Ryan Weaver4.7K views
Don't RTFM, WTFM - Open Source Documentation - German Perl Workshop 2010 by singingfish
Don't RTFM, WTFM - Open Source Documentation - German Perl Workshop 2010Don't RTFM, WTFM - Open Source Documentation - German Perl Workshop 2010
Don't RTFM, WTFM - Open Source Documentation - German Perl Workshop 2010
singingfish497 views
PECL Picks - Extensions to make your life better by ZendCon
PECL Picks - Extensions to make your life betterPECL Picks - Extensions to make your life better
PECL Picks - Extensions to make your life better
ZendCon4.1K views
How WebHooks Will Make Us All Programmers by Jeff Lindsay
How WebHooks Will Make Us All ProgrammersHow WebHooks Will Make Us All Programmers
How WebHooks Will Make Us All Programmers
Jeff Lindsay36.9K views
Puppet at GitHub / ChatOps by Puppet
Puppet at GitHub / ChatOpsPuppet at GitHub / ChatOps
Puppet at GitHub / ChatOps
Puppet48.4K views
Puppet at Pinterest by Puppet
Puppet at PinterestPuppet at Pinterest
Puppet at Pinterest
Puppet6.5K views
Rspec API Documentation by SmartLogic
Rspec API DocumentationRspec API Documentation
Rspec API Documentation
SmartLogic2.2K views
Cooking environments with chef by pythonandchips
Cooking environments with chefCooking environments with chef
Cooking environments with chef
pythonandchips1.3K views
APIs That Make Things Happen by Jeff Lindsay
APIs That Make Things HappenAPIs That Make Things Happen
APIs That Make Things Happen
Jeff Lindsay12.8K views
Puppet for SysAdmins by Puppet
Puppet for SysAdminsPuppet for SysAdmins
Puppet for SysAdmins
Puppet7.2K views
Cooking Perl with Chef by David Golden
Cooking Perl with ChefCooking Perl with Chef
Cooking Perl with Chef
David Golden4.6K views
Writing Software not Code with Cucumber by Ben Mabey
Writing Software not Code with CucumberWriting Software not Code with Cucumber
Writing Software not Code with Cucumber
Ben Mabey83.2K views
Distributed Applications with Perl & Gearman by Issac Goldstand
Distributed Applications with Perl & GearmanDistributed Applications with Perl & Gearman
Distributed Applications with Perl & Gearman
Issac Goldstand4.6K views
High Quality Symfony Bundles tutorial - Dutch PHP Conference 2014 by Matthias Noback
High Quality Symfony Bundles tutorial - Dutch PHP Conference 2014High Quality Symfony Bundles tutorial - Dutch PHP Conference 2014
High Quality Symfony Bundles tutorial - Dutch PHP Conference 2014
Matthias Noback12.4K views

Similar to Evented applications with RabbitMQ and CakePHP

Continuous Delivery for Python Developers – PyCon Otto by
Continuous Delivery for Python Developers – PyCon OttoContinuous Delivery for Python Developers – PyCon Otto
Continuous Delivery for Python Developers – PyCon OttoPeter Bittner
148 views38 slides
What is [Open] MPI? by
What is [Open] MPI?What is [Open] MPI?
What is [Open] MPI?Jeff Squyres
4.1K views24 slides
Scaling Streaming - Concepts, Research, Goals by
Scaling Streaming - Concepts, Research, GoalsScaling Streaming - Concepts, Research, Goals
Scaling Streaming - Concepts, Research, Goalskamaelian
765 views95 slides
Stackup deck by
Stackup deckStackup deck
Stackup deckEdwin Fuquen
302 views14 slides
The Art of Message Queues - TEKX by
The Art of Message Queues - TEKXThe Art of Message Queues - TEKX
The Art of Message Queues - TEKXMike Willbanks
8K views56 slides
Bp106 Worst Practices Final by
Bp106   Worst Practices FinalBp106   Worst Practices Final
Bp106 Worst Practices FinalBill Buchan
457 views37 slides

Similar to Evented applications with RabbitMQ and CakePHP(20)

Continuous Delivery for Python Developers – PyCon Otto by Peter Bittner
Continuous Delivery for Python Developers – PyCon OttoContinuous Delivery for Python Developers – PyCon Otto
Continuous Delivery for Python Developers – PyCon Otto
Peter Bittner148 views
What is [Open] MPI? by Jeff Squyres
What is [Open] MPI?What is [Open] MPI?
What is [Open] MPI?
Jeff Squyres4.1K views
Scaling Streaming - Concepts, Research, Goals by kamaelian
Scaling Streaming - Concepts, Research, GoalsScaling Streaming - Concepts, Research, Goals
Scaling Streaming - Concepts, Research, Goals
kamaelian765 views
The Art of Message Queues - TEKX by Mike Willbanks
The Art of Message Queues - TEKXThe Art of Message Queues - TEKX
The Art of Message Queues - TEKX
Mike Willbanks8K views
Bp106 Worst Practices Final by Bill Buchan
Bp106   Worst Practices FinalBp106   Worst Practices Final
Bp106 Worst Practices Final
Bill Buchan457 views
Why we choose Symfony2 by Merixstudio
Why we choose Symfony2Why we choose Symfony2
Why we choose Symfony2
Merixstudio388 views
Lunar Way and the Cloud Native "stack" by Kasper Nissen
Lunar Way and the Cloud Native "stack"Lunar Way and the Cloud Native "stack"
Lunar Way and the Cloud Native "stack"
Kasper Nissen694 views
Getting More Out of the Node.js, PHP, and Python Agents - AppSphere16 by AppDynamics
Getting More Out of the Node.js, PHP, and Python Agents - AppSphere16Getting More Out of the Node.js, PHP, and Python Agents - AppSphere16
Getting More Out of the Node.js, PHP, and Python Agents - AppSphere16
AppDynamics780 views
When to use Serverless? When to use Kubernetes? by Niklas Heidloff
When to use Serverless? When to use Kubernetes?When to use Serverless? When to use Kubernetes?
When to use Serverless? When to use Kubernetes?
Niklas Heidloff1.6K views
Localization (l10n) - The Process by Sundeep Anand
Localization (l10n) - The ProcessLocalization (l10n) - The Process
Localization (l10n) - The Process
Sundeep Anand1.9K views
Building A Great API - Evan Cooke, Cloudstock, December 2010 by Twilio Inc
Building A Great API - Evan Cooke, Cloudstock, December 2010Building A Great API - Evan Cooke, Cloudstock, December 2010
Building A Great API - Evan Cooke, Cloudstock, December 2010
Twilio Inc6.5K views
Managing Software Dependencies and the Supply Chain_ MIT EM.S20.pdf by Andrew Lamb
Managing Software Dependencies and the Supply Chain_ MIT EM.S20.pdfManaging Software Dependencies and the Supply Chain_ MIT EM.S20.pdf
Managing Software Dependencies and the Supply Chain_ MIT EM.S20.pdf
Andrew Lamb468 views
BinProxy: New Paradigm of Binary Analysis With Your Favorite Web Proxy by DONGJOO HA
BinProxy: New Paradigm of Binary Analysis With Your Favorite Web ProxyBinProxy: New Paradigm of Binary Analysis With Your Favorite Web Proxy
BinProxy: New Paradigm of Binary Analysis With Your Favorite Web Proxy
DONGJOO HA5.9K views
Manage your Public API Like a Protocol by Delyn Simons
Manage your Public API Like a ProtocolManage your Public API Like a Protocol
Manage your Public API Like a Protocol
Delyn Simons1.1K views
Production debugging web applications by Ido Flatow
Production debugging web applicationsProduction debugging web applications
Production debugging web applications
Ido Flatow535 views
DevOps - A Purpose for an Institution.pdf by Vishwas N
DevOps - A Purpose for an Institution.pdfDevOps - A Purpose for an Institution.pdf
DevOps - A Purpose for an Institution.pdf
Vishwas N6 views

More from markstory

Dependency injection in CakePHP by
Dependency injection in CakePHPDependency injection in CakePHP
Dependency injection in CakePHPmarkstory
758 views38 slides
Safer, More Helpful CakePHP by
Safer, More Helpful CakePHPSafer, More Helpful CakePHP
Safer, More Helpful CakePHPmarkstory
1.2K views31 slides
CakePHP - The Road Ahead by
CakePHP - The Road AheadCakePHP - The Road Ahead
CakePHP - The Road Aheadmarkstory
7.6K views64 slides
Future of HTTP in CakePHP by
Future of HTTP in CakePHPFuture of HTTP in CakePHP
Future of HTTP in CakePHPmarkstory
4.3K views55 slides
CakePHP mistakes made 2015 by
CakePHP mistakes made 2015CakePHP mistakes made 2015
CakePHP mistakes made 2015markstory
1.8K views42 slides
New in cakephp3 by
New in cakephp3New in cakephp3
New in cakephp3markstory
2.1K views44 slides

More from markstory(20)

Dependency injection in CakePHP by markstory
Dependency injection in CakePHPDependency injection in CakePHP
Dependency injection in CakePHP
markstory758 views
Safer, More Helpful CakePHP by markstory
Safer, More Helpful CakePHPSafer, More Helpful CakePHP
Safer, More Helpful CakePHP
markstory1.2K views
CakePHP - The Road Ahead by markstory
CakePHP - The Road AheadCakePHP - The Road Ahead
CakePHP - The Road Ahead
markstory7.6K views
Future of HTTP in CakePHP by markstory
Future of HTTP in CakePHPFuture of HTTP in CakePHP
Future of HTTP in CakePHP
markstory4.3K views
CakePHP mistakes made 2015 by markstory
CakePHP mistakes made 2015CakePHP mistakes made 2015
CakePHP mistakes made 2015
markstory1.8K views
New in cakephp3 by markstory
New in cakephp3New in cakephp3
New in cakephp3
markstory2.1K views
PHP WTF by markstory
PHP WTFPHP WTF
PHP WTF
markstory7.1K views
CakePHP 3.0 and beyond by markstory
CakePHP 3.0 and beyondCakePHP 3.0 and beyond
CakePHP 3.0 and beyond
markstory3K views
CakePHP mistakes made confoo 2015 by markstory
CakePHP mistakes made confoo 2015CakePHP mistakes made confoo 2015
CakePHP mistakes made confoo 2015
markstory943 views
Performance and optimization CakeFest 2014 by markstory
Performance and optimization CakeFest 2014Performance and optimization CakeFest 2014
Performance and optimization CakeFest 2014
markstory1.6K views
Road to CakePHP 3.0 by markstory
Road to CakePHP 3.0Road to CakePHP 3.0
Road to CakePHP 3.0
markstory11.1K views
Performance and optimization by markstory
Performance and optimizationPerformance and optimization
Performance and optimization
markstory2.6K views
OWASP Top 10 2013 by markstory
OWASP Top 10 2013OWASP Top 10 2013
OWASP Top 10 2013
markstory7.6K views
CakePHP the yum & yuck by markstory
CakePHP the yum & yuckCakePHP the yum & yuck
CakePHP the yum & yuck
markstory4.6K views
Introduction to Twig by markstory
Introduction to TwigIntroduction to Twig
Introduction to Twig
markstory7.7K views
Owasp top 10 by markstory
Owasp top 10Owasp top 10
Owasp top 10
markstory9.2K views
Simple search with elastic search by markstory
Simple search with elastic searchSimple search with elastic search
Simple search with elastic search
markstory6.6K views
Making the most of 2.2 by markstory
Making the most of 2.2Making the most of 2.2
Making the most of 2.2
markstory1.2K views
Intro to continuous integration by markstory
Intro to continuous integration Intro to continuous integration
Intro to continuous integration
markstory1.1K views
PHPunit and you by markstory
PHPunit and youPHPunit and you
PHPunit and you
markstory2.1K views

Recently uploaded

Scaling Knowledge Graph Architectures with AI by
Scaling Knowledge Graph Architectures with AIScaling Knowledge Graph Architectures with AI
Scaling Knowledge Graph Architectures with AIEnterprise Knowledge
30 views15 slides
handbook for web 3 adoption.pdf by
handbook for web 3 adoption.pdfhandbook for web 3 adoption.pdf
handbook for web 3 adoption.pdfLiveplex
22 views16 slides
STPI OctaNE CoE Brochure.pdf by
STPI OctaNE CoE Brochure.pdfSTPI OctaNE CoE Brochure.pdf
STPI OctaNE CoE Brochure.pdfmadhurjyapb
14 views1 slide
Empathic Computing: Delivering the Potential of the Metaverse by
Empathic Computing: Delivering  the Potential of the MetaverseEmpathic Computing: Delivering  the Potential of the Metaverse
Empathic Computing: Delivering the Potential of the MetaverseMark Billinghurst
478 views80 slides
The Research Portal of Catalonia: Growing more (information) & more (services) by
The Research Portal of Catalonia: Growing more (information) & more (services)The Research Portal of Catalonia: Growing more (information) & more (services)
The Research Portal of Catalonia: Growing more (information) & more (services)CSUC - Consorci de Serveis Universitaris de Catalunya
80 views25 slides
STKI Israeli Market Study 2023 corrected forecast 2023_24 v3.pdf by
STKI Israeli Market Study 2023   corrected forecast 2023_24 v3.pdfSTKI Israeli Market Study 2023   corrected forecast 2023_24 v3.pdf
STKI Israeli Market Study 2023 corrected forecast 2023_24 v3.pdfDr. Jimmy Schwarzkopf
19 views29 slides

Recently uploaded(20)

handbook for web 3 adoption.pdf by Liveplex
handbook for web 3 adoption.pdfhandbook for web 3 adoption.pdf
handbook for web 3 adoption.pdf
Liveplex22 views
STPI OctaNE CoE Brochure.pdf by madhurjyapb
STPI OctaNE CoE Brochure.pdfSTPI OctaNE CoE Brochure.pdf
STPI OctaNE CoE Brochure.pdf
madhurjyapb14 views
Empathic Computing: Delivering the Potential of the Metaverse by Mark Billinghurst
Empathic Computing: Delivering  the Potential of the MetaverseEmpathic Computing: Delivering  the Potential of the Metaverse
Empathic Computing: Delivering the Potential of the Metaverse
Mark Billinghurst478 views
STKI Israeli Market Study 2023 corrected forecast 2023_24 v3.pdf by Dr. Jimmy Schwarzkopf
STKI Israeli Market Study 2023   corrected forecast 2023_24 v3.pdfSTKI Israeli Market Study 2023   corrected forecast 2023_24 v3.pdf
STKI Israeli Market Study 2023 corrected forecast 2023_24 v3.pdf
Data Integrity for Banking and Financial Services by Precisely
Data Integrity for Banking and Financial ServicesData Integrity for Banking and Financial Services
Data Integrity for Banking and Financial Services
Precisely21 views
Piloting & Scaling Successfully With Microsoft Viva by Richard Harbridge
Piloting & Scaling Successfully With Microsoft VivaPiloting & Scaling Successfully With Microsoft Viva
Piloting & Scaling Successfully With Microsoft Viva
Business Analyst Series 2023 - Week 3 Session 5 by DianaGray10
Business Analyst Series 2023 -  Week 3 Session 5Business Analyst Series 2023 -  Week 3 Session 5
Business Analyst Series 2023 - Week 3 Session 5
DianaGray10248 views
Unit 1_Lecture 2_Physical Design of IoT.pdf by StephenTec
Unit 1_Lecture 2_Physical Design of IoT.pdfUnit 1_Lecture 2_Physical Design of IoT.pdf
Unit 1_Lecture 2_Physical Design of IoT.pdf
StephenTec12 views
Serverless computing with Google Cloud (2023-24) by wesley chun
Serverless computing with Google Cloud (2023-24)Serverless computing with Google Cloud (2023-24)
Serverless computing with Google Cloud (2023-24)
wesley chun11 views
AMAZON PRODUCT RESEARCH.pdf by JerikkLaureta
AMAZON PRODUCT RESEARCH.pdfAMAZON PRODUCT RESEARCH.pdf
AMAZON PRODUCT RESEARCH.pdf
JerikkLaureta26 views
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N... by James Anderson
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
James Anderson85 views
SAP Automation Using Bar Code and FIORI.pdf by Virendra Rai, PMP
SAP Automation Using Bar Code and FIORI.pdfSAP Automation Using Bar Code and FIORI.pdf
SAP Automation Using Bar Code and FIORI.pdf
Voice Logger - Telephony Integration Solution at Aegis by Nirmal Sharma
Voice Logger - Telephony Integration Solution at AegisVoice Logger - Telephony Integration Solution at Aegis
Voice Logger - Telephony Integration Solution at Aegis
Nirmal Sharma39 views
Igniting Next Level Productivity with AI-Infused Data Integration Workflows by Safe Software
Igniting Next Level Productivity with AI-Infused Data Integration Workflows Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Safe Software263 views

Evented applications with RabbitMQ and CakePHP