SlideShare a Scribd company logo
Real time system
performance monitoring
      AMQP and
  CatalystX::JobServer
         Tomas (t0m) Doran
         São Paulo.pm perl workshop 2010
Aka the “my code
doesn’t work yet” talk
• I wrote half the slides for this at 6am Friday
  (São Paulo time)
• The title is a bit misleading, as I wrote the
  talk abstract in March, then wrote entirely
  different software.
• Sorry about that.
Message queueing

• Lets not talk about the (not working) code
  just yet...
• This talk is about Message Queueing.
• What is Message Queueing?
• Why would I want to use it?
What is message
       queueing.
• In it’s simplest form, it’s just a list.
• 1 (or more) ‘producers’ (writers)
• 1 (or more) ‘consumers’ (readers)
• Queue if rate of production > rate of
  consumption
Why do I want it?
• Decouples producers and consumers
  (probably across the network).
• Lets you manage load, and spikes in load
  (only n consumers).
• In a web environment - lets you serve
  more pages, quicker.
Other cases
• View as a list a little simplistic.
• Depending on your application, you may
  want:
 • One to one
 • One to many
 • One to many (broadcast)
 • Many to all of the above
 • More complex topology?
AMQP

• Queuing protocol
• Fast
• Interoperable (maybe?)
AMQP

       AMQP enables complete
    interoperability for messaging
  middleware, both the networking
protocol and the semantics of broker
   services are defined in AMQP.
AMQP


Say what?
AMQP

• Full abstraction of all the mechanics of
  messaging across the network.
• Serialization and framing of messages.
• Wiring of message routing is part of the
  protocol.
AMQP

• So all your clients know (at least half) of
  the wiring.
• Different topologies depending on routing
  configuration.
• Can specify other options such as durability
• Nice when your server dies - no ‘current
  config’
AMQP Concepts
              RabbitMQ


                vhost



  Publisher   Exchange




               Queue
  Consumer
Concepts - Exchanges

• Named
• Messages are published (sent) to one
  exchange
• Can be durable (lasts till deleted), or auto-
  deleted
Queues
• Queues can be named or (or named by the
  server - private queues).
• Queues are bound to one (or more)
  exchanges.
• Queues can have 0 or more clients
• Queues may persist with 0 clients or not.
• FIFO (if you have 1 consumer)
• Message never delivered to > 1 client
Bindings


• Binding is what joins a queue and an
  exchange.
Traditional queue
• Named exchange
• Bound to 1 Named queue
• 0 or more listeners get round-robin
  messages
• Messages queue when nobody listens / if
  consumers are slow
Broadcast
• Named exchange
• Each client creates an anonymous
  ephermeral queue
• Client binds the queue to that exchange
• All clients get all messages
• Messages go to /dev/null if no clients
Others

• Different exchange types - direct, topic,
  fanout
• You can do a lot using just these and a mix
  of named and anonymous queues
• More complex topologies possible
I accidentally wrote
         software

• I try to avoid doing this
• I’m not very good at it ;)
I blame Net::RabbitFoot
• It’s written using AnyEvent and Coro
• Which I hadn’t used before, but looked
  good for this type of thing.
• I felt my way around writing simple things
  standalone.
• Got all the web servers logging into Rabbit
Logging into message
       queuing
• Good example of broadcast
• Want to aggregate logs to files
• And be able to ‘tail’ them
• Logging directly from the application
• Also tailing (normal) log files to message
  queue
Getting the logs back
Ok, there is some setup
Ok, there is some setup
Dumping them to a file

• That’s pretty simple after that..
• Except:
 • Log rotation
 • Not flushing to disk once per message
 • etc...
Viewing them live

• Someone wrote an AMQP client in flash
• AMQP security model not useful publicly
• Cute prototype
• (Sorry, no demo - refuses to work locally)
Queueing Jobs

• Next application, simple job queue.
• 1 worker, serialized.. (Crap, good enough)
• Log JSON into RabbitMQ (again), inflate,
  call the ->run method.
• Works!
Job Server
• I now have several scripts, all doing bits
  with queuing. All duplicating code.
• I want to aggregate messages
• Send messages of aggregates at regular
  intervals
• Need something more generic
Job server
• Wrote a simple abstraction on getting
  channels, making exchanges and queues, etc
• Was still going to end up with a load of
  scripts/jobs that needed running and
  managing.Yuk.
• Inspecting the state of each job ‘service’
  hard / boring..
But wait
• Each ‘thing’ (timer, listener, logger, emitter,
  worker etc) can be an instance of a class
  with attributes for the state.
• Construct a set from some config file.
• Lets me aggregate jobs together / share
  code (Can use AnyEvent/Coro for threads).
• Less processes to manage. Working out the
  state just got harder still.
But wait
• Make all the classes use MooseX::Storage
• Catalyst makes instances of things from
  config...
• So, I could adapt all these instances into
  Catalyst models, write a controller, done!
• Erm, but Catalyst, and message queueing,
  and what?!?!?
I blame Miyagawa
• For Plack, and Catalyst::Engine::Plack, and
  Corona (the Coro PSGI server).
• I had this INSANE idea one night.
• I tried it.
• IT WORKED.
• WOAH.
I blame clkao

• Next step - browser kicks off a job.
• Status via long poll?
• He did it already!
• With long hair!
Hippie
• Async pipe to the browser.
• Abstracts all the nasty ajax details (also
  does long poll, or websockets)
• Applications:
 • Automatically updated monitor of app
    components
  • Start a job and then get an AJAX update
    screen for the job progress.
Useable?
• The basics work.
• Running it production at work
• (Since WedneThursday....)
• If you need a high volume, simple,
  production ready job scheduler right
  now, use Gearman.
Useable?

• Needs my github versions of
  Catalyst::Engine::PSGI and Web::Hippie
• Running jobs from the web app doesn’t
  work/exist yet.
• All the pieces are there - next week?
Demo?
Next steps?
• Production battle scars ;)
• Hippie for watching jobs run, not just
  component status updates.
• Docs would be good...
• Hippe::Pipe for bidirectional
• More traits / plugins / components
What to go look at

• http://www.rabbitmq.com
• Docs, setup info, FAQ
• Slideshare - lots of good and more detailed
  AMQP introductions.
What to go look at
       (CPAN)
• Net::RabbitFoot
• App::RabbitTail
• Plack
• Web::Hippie
• CatalystX::JobServer (github)
Bonus slide!

• I forgot to mention this originally...
• DO NOT FORK AFTER USING
  Net::RabbitFoot (and then try to use it in
  the child process)
• This will go horribly horribly wrong.
Other solutions

• Gearman
• STOMP
 • ActiveMQ (or Rabbit has a STOMP
    adaptor)
 • Catalyst::Engine::STOMP
Thanks!

• Questions?
• Anyone interested in playing, grab me on irc
• Happy to hand-hold as I need more people
  using this.
• I’ll love you forever if you write docs.

More Related Content

KEY
RabbitMQ And Nanite
PDF
RabbitMQ in PHP
PDF
What’s New in RabbitMQ 3.8?
PPT
Rabbit MQ introduction
PPTX
Java Messaging with AMQP and RabbitMQ
PDF
Introduction to AMQP Messaging with RabbitMQ
PPTX
Message Broker System and RabbitMQ
PDF
Full Stack Bus with Javascript, RabbitMQ and Postal.js
RabbitMQ And Nanite
RabbitMQ in PHP
What’s New in RabbitMQ 3.8?
Rabbit MQ introduction
Java Messaging with AMQP and RabbitMQ
Introduction to AMQP Messaging with RabbitMQ
Message Broker System and RabbitMQ
Full Stack Bus with Javascript, RabbitMQ and Postal.js

What's hot (20)

PDF
AMQP with RabbitMQ
PPTX
The RabbitMQ Message Broker
PDF
RabbitMQ & Hutch
PDF
Messaging Standards and Systems - AMQP & RabbitMQ
PDF
Messaging Standards and Systems - AMQP & RabbitMQ
PDF
An update from the RabbitMQ team - Michael Klishin
PDF
XMPP & AMQP
PDF
Messaging with RabbitMQ and AMQP
PDF
AMQP for phpMelb
PDF
Distributed messaging with AMQP
PDF
RabbitMQ fairly-indepth
PDF
A walk-through of the design and architecture of RabbitMQ - Ayanda Dube
PPT
Amqp Basic
PDF
[@NaukriEngineering] Messaging Queues
PPTX
Spring RabbitMQ
PDF
ODP
Introduction To RabbitMQ
PDF
Messaging with amqp and rabbitmq
PDF
Integrating PostgreSql with RabbitMQ
PPTX
Scaling application with RabbitMQ
AMQP with RabbitMQ
The RabbitMQ Message Broker
RabbitMQ & Hutch
Messaging Standards and Systems - AMQP & RabbitMQ
Messaging Standards and Systems - AMQP & RabbitMQ
An update from the RabbitMQ team - Michael Klishin
XMPP & AMQP
Messaging with RabbitMQ and AMQP
AMQP for phpMelb
Distributed messaging with AMQP
RabbitMQ fairly-indepth
A walk-through of the design and architecture of RabbitMQ - Ayanda Dube
Amqp Basic
[@NaukriEngineering] Messaging Queues
Spring RabbitMQ
Introduction To RabbitMQ
Messaging with amqp and rabbitmq
Integrating PostgreSql with RabbitMQ
Scaling application with RabbitMQ
Ad

Similar to Real time system_performance_mon (20)

KEY
Cooking a rabbit pie
KEY
High scale flavour
ODP
The Art of Message Queues - TEKX
PDF
Distributed and concurrent programming with RabbitMQ and EventMachine Rails U...
PDF
Architecture | The Future of Messaging: RabbitMQ and AMQP | Eberhard Wolff
PDF
Follow the White Rabbit - Message Queues with PHP
PDF
The Future of Messaging: RabbitMQ and AMQP
ZIP
Message Queues in Ruby - An Overview
ODP
Introduction to Python Celery
PDF
Evented applications with RabbitMQ and CakePHP
PDF
Life in a Queue - Using Message Queue with django
PDF
%w(map reduce).first - A Tale About Rabbits, Latency, and Slim Crontabs
PDF
Построение распределенной системы сбора данных с помощью RabbitMQ, Alvaro Vid...
PDF
RabbitMQ with python and ruby RuPy 2009
PDF
Microservices communication styles and event bus
ODP
Art Of Message Queues
PDF
Queue Everything and Please Everyone
PDF
On Rabbits and Elephants
PPTX
RabbitMQ 101 : How to cook the rabbit? - phptour 2016
Cooking a rabbit pie
High scale flavour
The Art of Message Queues - TEKX
Distributed and concurrent programming with RabbitMQ and EventMachine Rails U...
Architecture | The Future of Messaging: RabbitMQ and AMQP | Eberhard Wolff
Follow the White Rabbit - Message Queues with PHP
The Future of Messaging: RabbitMQ and AMQP
Message Queues in Ruby - An Overview
Introduction to Python Celery
Evented applications with RabbitMQ and CakePHP
Life in a Queue - Using Message Queue with django
%w(map reduce).first - A Tale About Rabbits, Latency, and Slim Crontabs
Построение распределенной системы сбора данных с помощью RabbitMQ, Alvaro Vid...
RabbitMQ with python and ruby RuPy 2009
Microservices communication styles and event bus
Art Of Message Queues
Queue Everything and Please Everyone
On Rabbits and Elephants
RabbitMQ 101 : How to cook the rabbit? - phptour 2016
Ad

More from Tomas Doran (20)

PPTX
Long haul infrastructure: Failures and successes
PDF
Empowering developers to deploy their own data stores
PDF
Dockersh and a brief intro to the docker internals
PDF
Sensu and Sensibility - Puppetconf 2014
PDF
Steamlining your puppet development workflow
PDF
Building a smarter application stack - service discovery and wiring for Docker
PDF
Chasing AMI - Building Amazon machine images with Puppet, Packer and Jenkins
PPT
Deploying puppet code at light speed
PDF
Thinking through puppet code layout
PDF
Docker puppetcamp london 2013
PDF
"The worst code I ever wrote"
PDF
Test driven infrastructure development (2 - puppetconf 2013 edition)
PDF
Test driven infrastructure development
PPT
London devops - orc
KEY
London devops logging
KEY
Message:Passing - lpw 2012
KEY
Webapp security testing
KEY
Webapp security testing
KEY
Dates aghhhh!!?!?!?!
KEY
Messaging, interoperability and log aggregation - a new framework
Long haul infrastructure: Failures and successes
Empowering developers to deploy their own data stores
Dockersh and a brief intro to the docker internals
Sensu and Sensibility - Puppetconf 2014
Steamlining your puppet development workflow
Building a smarter application stack - service discovery and wiring for Docker
Chasing AMI - Building Amazon machine images with Puppet, Packer and Jenkins
Deploying puppet code at light speed
Thinking through puppet code layout
Docker puppetcamp london 2013
"The worst code I ever wrote"
Test driven infrastructure development (2 - puppetconf 2013 edition)
Test driven infrastructure development
London devops - orc
London devops logging
Message:Passing - lpw 2012
Webapp security testing
Webapp security testing
Dates aghhhh!!?!?!?!
Messaging, interoperability and log aggregation - a new framework

Recently uploaded (20)

PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
Cloud computing and distributed systems.
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
A Presentation on Artificial Intelligence
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Modernizing your data center with Dell and AMD
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Approach and Philosophy of On baking technology
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
cuic standard and advanced reporting.pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
KodekX | Application Modernization Development
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
Big Data Technologies - Introduction.pptx
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Cloud computing and distributed systems.
Diabetes mellitus diagnosis method based random forest with bat algorithm
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
A Presentation on Artificial Intelligence
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Review of recent advances in non-invasive hemoglobin estimation
Modernizing your data center with Dell and AMD
Digital-Transformation-Roadmap-for-Companies.pptx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Approach and Philosophy of On baking technology
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
cuic standard and advanced reporting.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
KodekX | Application Modernization Development
NewMind AI Weekly Chronicles - August'25 Week I
Spectral efficient network and resource selection model in 5G networks
Big Data Technologies - Introduction.pptx

Real time system_performance_mon

  • 1. Real time system performance monitoring AMQP and CatalystX::JobServer Tomas (t0m) Doran São Paulo.pm perl workshop 2010
  • 2. Aka the “my code doesn’t work yet” talk • I wrote half the slides for this at 6am Friday (São Paulo time) • The title is a bit misleading, as I wrote the talk abstract in March, then wrote entirely different software. • Sorry about that.
  • 3. Message queueing • Lets not talk about the (not working) code just yet... • This talk is about Message Queueing. • What is Message Queueing? • Why would I want to use it?
  • 4. What is message queueing. • In it’s simplest form, it’s just a list. • 1 (or more) ‘producers’ (writers) • 1 (or more) ‘consumers’ (readers) • Queue if rate of production > rate of consumption
  • 5. Why do I want it? • Decouples producers and consumers (probably across the network). • Lets you manage load, and spikes in load (only n consumers). • In a web environment - lets you serve more pages, quicker.
  • 6. Other cases • View as a list a little simplistic. • Depending on your application, you may want: • One to one • One to many • One to many (broadcast) • Many to all of the above • More complex topology?
  • 7. AMQP • Queuing protocol • Fast • Interoperable (maybe?)
  • 8. AMQP AMQP enables complete interoperability for messaging middleware, both the networking protocol and the semantics of broker services are defined in AMQP.
  • 10. AMQP • Full abstraction of all the mechanics of messaging across the network. • Serialization and framing of messages. • Wiring of message routing is part of the protocol.
  • 11. AMQP • So all your clients know (at least half) of the wiring. • Different topologies depending on routing configuration. • Can specify other options such as durability • Nice when your server dies - no ‘current config’
  • 12. AMQP Concepts RabbitMQ vhost Publisher Exchange Queue Consumer
  • 13. Concepts - Exchanges • Named • Messages are published (sent) to one exchange • Can be durable (lasts till deleted), or auto- deleted
  • 14. Queues • Queues can be named or (or named by the server - private queues). • Queues are bound to one (or more) exchanges. • Queues can have 0 or more clients • Queues may persist with 0 clients or not. • FIFO (if you have 1 consumer) • Message never delivered to > 1 client
  • 15. Bindings • Binding is what joins a queue and an exchange.
  • 16. Traditional queue • Named exchange • Bound to 1 Named queue • 0 or more listeners get round-robin messages • Messages queue when nobody listens / if consumers are slow
  • 17. Broadcast • Named exchange • Each client creates an anonymous ephermeral queue • Client binds the queue to that exchange • All clients get all messages • Messages go to /dev/null if no clients
  • 18. Others • Different exchange types - direct, topic, fanout • You can do a lot using just these and a mix of named and anonymous queues • More complex topologies possible
  • 19. I accidentally wrote software • I try to avoid doing this • I’m not very good at it ;)
  • 20. I blame Net::RabbitFoot • It’s written using AnyEvent and Coro • Which I hadn’t used before, but looked good for this type of thing. • I felt my way around writing simple things standalone. • Got all the web servers logging into Rabbit
  • 21. Logging into message queuing • Good example of broadcast • Want to aggregate logs to files • And be able to ‘tail’ them • Logging directly from the application • Also tailing (normal) log files to message queue
  • 23. Ok, there is some setup
  • 24. Ok, there is some setup
  • 25. Dumping them to a file • That’s pretty simple after that.. • Except: • Log rotation • Not flushing to disk once per message • etc...
  • 26. Viewing them live • Someone wrote an AMQP client in flash • AMQP security model not useful publicly • Cute prototype • (Sorry, no demo - refuses to work locally)
  • 27. Queueing Jobs • Next application, simple job queue. • 1 worker, serialized.. (Crap, good enough) • Log JSON into RabbitMQ (again), inflate, call the ->run method. • Works!
  • 28. Job Server • I now have several scripts, all doing bits with queuing. All duplicating code. • I want to aggregate messages • Send messages of aggregates at regular intervals • Need something more generic
  • 29. Job server • Wrote a simple abstraction on getting channels, making exchanges and queues, etc • Was still going to end up with a load of scripts/jobs that needed running and managing.Yuk. • Inspecting the state of each job ‘service’ hard / boring..
  • 30. But wait • Each ‘thing’ (timer, listener, logger, emitter, worker etc) can be an instance of a class with attributes for the state. • Construct a set from some config file. • Lets me aggregate jobs together / share code (Can use AnyEvent/Coro for threads). • Less processes to manage. Working out the state just got harder still.
  • 31. But wait • Make all the classes use MooseX::Storage • Catalyst makes instances of things from config... • So, I could adapt all these instances into Catalyst models, write a controller, done! • Erm, but Catalyst, and message queueing, and what?!?!?
  • 32. I blame Miyagawa • For Plack, and Catalyst::Engine::Plack, and Corona (the Coro PSGI server). • I had this INSANE idea one night. • I tried it. • IT WORKED. • WOAH.
  • 33. I blame clkao • Next step - browser kicks off a job. • Status via long poll? • He did it already! • With long hair!
  • 34. Hippie • Async pipe to the browser. • Abstracts all the nasty ajax details (also does long poll, or websockets) • Applications: • Automatically updated monitor of app components • Start a job and then get an AJAX update screen for the job progress.
  • 35. Useable? • The basics work. • Running it production at work • (Since WedneThursday....) • If you need a high volume, simple, production ready job scheduler right now, use Gearman.
  • 36. Useable? • Needs my github versions of Catalyst::Engine::PSGI and Web::Hippie • Running jobs from the web app doesn’t work/exist yet. • All the pieces are there - next week?
  • 37. Demo?
  • 38. Next steps? • Production battle scars ;) • Hippie for watching jobs run, not just component status updates. • Docs would be good... • Hippe::Pipe for bidirectional • More traits / plugins / components
  • 39. What to go look at • http://www.rabbitmq.com • Docs, setup info, FAQ • Slideshare - lots of good and more detailed AMQP introductions.
  • 40. What to go look at (CPAN) • Net::RabbitFoot • App::RabbitTail • Plack • Web::Hippie • CatalystX::JobServer (github)
  • 41. Bonus slide! • I forgot to mention this originally... • DO NOT FORK AFTER USING Net::RabbitFoot (and then try to use it in the child process) • This will go horribly horribly wrong.
  • 42. Other solutions • Gearman • STOMP • ActiveMQ (or Rabbit has a STOMP adaptor) • Catalyst::Engine::STOMP
  • 43. Thanks! • Questions? • Anyone interested in playing, grab me on irc • Happy to hand-hold as I need more people using this. • I’ll love you forever if you write docs.