SlideShare une entreprise Scribd logo
1  sur  46
Real time system performance monitoring
     AMQP and CatalystX::JobServer

     Cooking a
     Rabbit pie
                Tomas (t0m) Doran
                São Paulo.pm perl workshop 2010
                London perl workshop 2010
I accidentally wrote
         software

• I try to avoid doing this
• I’m not very good at it ;)
Aka the “my code still
doesn’t work yet” talk
• This is the 2nd time I’ve talked about
  AMQP stuff this year.
• Half the code still isn’t properly production
  ready.
• It’s an order of magnitude better than last
  time round ;)
Message queueing

• Lets not talk about the code just yet...
• This talk is about Message Queueing and
  specifically AMQP.
• I’m going to assume if you knew nothing,
  you went to the earlier talk - not going to
  duplicate too much.
AMQP Concepts
              RabbitMQ


                vhost



  Publisher   Exchange




               Queue
  Consumer
AMQP

• 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’
Routing keys
• Each message sent to an exchange has a
  routing key.
• Each queue can be bound to exchanges
  with routing keys
• I.e. you can subscribe to thingsilike.meat
  and thingsilike.beer on an exchange, but not
  subscribe to thingsilike.classicalmusic
• Wildcards - # and *
AMQP Delivery modes
• Two modes of consuming messages
 • Get - Gets a single message from the
    queue
 • Subscribe - server sends messages from
    the queue to the client until cancelled
• Durability - exchange and queue must
  agree
• Explicit ACK possible but not required
Non-trivial message
    queueing
• Flexible topologies.
• Each queue can bind to multiple
  exchanges, with multiple routing keys.
• Routing can be dynamic.
• E.g. one client can ‘tail’ a log, but then re-
  bind with a different routing key to get a
  different subset of messages.
Custom Exchanges

• RabbitMQ allows pluggable exchange types
• Simplest and most useful example is the
  ‘emit last message on bind’ exchange
• New consumers get the last message seen
  on the exchange
I wanted to play with
      RabbitMQ
• I blame Net::RabbitFoot
• It’s written using AnyEvent
• 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
Practical example:
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 live demo - it hated me when I
  tried to make it work again)
Queueing Jobs

• New skool scripts - MX::Getopt and a -
  >run method
• Add MooseX::Storage
• You can flatten a script as JSON, send it
  over the wire, re-inflate it, call the ->run
  method.
Message Queueing
      Framework?
• I now have several scripts, all doing bits
  with queuing. All duplicating code.
• I want to run batch jobs
• I want to aggregate log messages (e.g.
  average web requests per min).
• I want to log messages to file(s)
• I want to broadcast (and log) aggregates
• Need something more generic
Most urgent problem:
     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) an instance with state in
  attributes - traits => [‘Serialize’]
• Construct a instances from config file.
• One process managing each machine’s
  tasks.
• Less processes to manage, win. Working
  out the state just got harder still, FAIL.
But wait
• Make all the classes use MooseX::Storage
• Catalyst makes instances of things from
  config...
• Build Catalyst app from config file at boot
• 2 Trivial controllers introspect entire app
• State monitoring (nagios, munin, debugging)
  now trivial
Really really trivial
Hubris
• I could have just used Gearman for my
  jobs.
• I could have come up with a simpler
  solution for logging and aggregation.
• I was having fun.

• Until I tried running it in production.
Hubris
• I could have just used Gearman for my
  jobs.
• I could have come up with a simpler
  solution for logging and aggregation.
• I was having fun.

• Until I tried running it in production.
Hubris
• I could have just used Gearman for my
  jobs.
• I could have come up with a simpler
  solution for logging and aggregation.
• I was having fun.

• It crashed and burned in production.
• sys programming, async, pluggable, FUUUU
Hubris
• I could have just used Gearman for my
  jobs.
• I could have come up with a simpler
  solution for logging and aggregation.
• I was having fun.

• It crashed and burned in production.
• sys programming, async, pluggable, FUUUU
I learnt a lot
• I knew a lot in theory before. Doing it is
  somewhat harder :)


• It doesn’t crash any more.
• Or leak fds
• Still not perfect (e.g. doesn’t reconnect
  right if mq falls over)
Why laziness didn’t win.
• Brad’s code is great, until you try not being
  Livejournal.
• My day job is nothing like Livejournal.

• I was still very excited about AMQP
• I had a talk to write for a conference (and I
  could avoid writing it by writing software)
• Hippie rocked my world
Web 2.0
• Lots of Javascript, update pages dynamically
• Messages already JSON from MX::Storage
• comet - long poll, multipart xhr
• Joose.Storage - inflate your objects in
  Javascript
• Present data from message queues to the
  user as it becomes available.
• Hippie - painless comet - rocked my world
Web::Hippie
• Async pipe to the browser.
• Abstracts all the nasty ajax details (also
  does long poll, or websockets)
• Applications (I had a practical use for):
  •   Interactive log tail. Realtime systems graphs.

  •   Instant feedback from long running batch jobs

  •   ‘Social’ features by broadcasting/aggregating data
Job Statuses

• We inflate JSON data to $job
• $job->run($status_cb);
• $status_cb->( CompletionEstimate-
  >new( percent => 50 ) );
Job Statuses
• All jobs have a UUID
• Job statuses - ‘Running/Complete/StatusLine/
  CompletionEstimate/RunJob’
• Ask for a pipe to some UUID(s)
• Draw nice progress indicators
• Further jobs can be included (RunJob magic)
• Custom statuses trivial - perl class with
  attributes, Javascript class with display logic
Wait a second
•   I don’t want the unwashed masses making HTTP
    connections to machines running jobs.

•   Ergo: Send all the job statuses to an exchange, use
    UUID as routing key.

•   Optional ‘Hippies’ controller - client produces a
    set of keys, these sprintf => routing keys.

•   Hippie pipe => one queue per-client queue bound
    to keys they want.

•   ‘RunJob’ messages automatically binds extra key,
    so you see things triggered by things you are
    watching.
How it all hangs together
Useable?
• Running jobs works.
• Running it in production at work. It doesn’t
  crash any more.
• Status pipe stuff not deployed to clients yet.
• If you need a high volume, simple,
  production ready job scheduler, right
  now, use Gearman.
Demo?
Demo 1

• Simple job server
• Enqueues 10 jobs at start
• 1 worker process
• JSON status of app
• Add workers dynamically
Demo 2

• Publish component status to queue
  regularly
• Simple CLI script tailing queue
• Jobs indexed by UUID - allows Hippie
Demo 3

• Status updates from ‘Job Server’ published.
• 2nd ‘/hippies’ process binds queue to
  exchange for some UUIDs.
• Gets ‘RunJob’ notifications, and statuses
  when they run.
Next steps?
• Reliability - recover from errors better.
• Expose more stats about MQ use.
• Better (some!) logging.
• Docs would be good...
• Hippe::Pipe for bidirectional
• More traits / plugins / components
• More / better stock Javascript
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 / Twiggy
• Web::Hippie
• CatalystX::JobServer (github.com/bobtfish/
  CatalystX-JobServer)
Other solutions

• Gearman
• STOMP
 • ActiveMQ (or Rabbit has a STOMP
    adaptor - good luck)
 • Catalyst::Engine::STOMP
Thanks!
• Questions?
• Anyone interested in playing, feel free to
  grab me on irc (t0m @ magnet &
  Freenode)
• Happy to hand-hold as I need more people
  using this.
• I’ll love you forever if you write docs.

Contenu connexe

Tendances

Making Symfony Services async with RabbitMq (and more Symfony)
Making Symfony Services async with RabbitMq (and more Symfony)Making Symfony Services async with RabbitMq (and more Symfony)
Making Symfony Services async with RabbitMq (and more Symfony)
Gaetano Giunta
 

Tendances (20)

Making Symfony Services async with RabbitMq (and more Symfony)
Making Symfony Services async with RabbitMq (and more Symfony)Making Symfony Services async with RabbitMq (and more Symfony)
Making Symfony Services async with RabbitMq (and more Symfony)
 
Great Tools Heavily Used In Japan, You Don't Know.
Great Tools Heavily Used In Japan, You Don't Know.Great Tools Heavily Used In Japan, You Don't Know.
Great Tools Heavily Used In Japan, You Don't Know.
 
Puppet Development Workflow
Puppet Development WorkflowPuppet Development Workflow
Puppet Development Workflow
 
High performance network programming on the jvm oscon 2012
High performance network programming on the jvm   oscon 2012 High performance network programming on the jvm   oscon 2012
High performance network programming on the jvm oscon 2012
 
Erlang factory SF 2011 "Erlang and the big switch in social games"
Erlang factory SF 2011 "Erlang and the big switch in social games"Erlang factory SF 2011 "Erlang and the big switch in social games"
Erlang factory SF 2011 "Erlang and the big switch in social games"
 
Hybrid concurrency patterns
Hybrid concurrency patternsHybrid concurrency patterns
Hybrid concurrency patterns
 
Developer-friendly taskqueues: What you should ask yourself before choosing one
Developer-friendly taskqueues: What you should ask yourself before choosing oneDeveloper-friendly taskqueues: What you should ask yourself before choosing one
Developer-friendly taskqueues: What you should ask yourself before choosing one
 
Queue your work
Queue your workQueue your work
Queue your work
 
Woo: Writing a fast web server
Woo: Writing a fast web serverWoo: Writing a fast web server
Woo: Writing a fast web server
 
PyCon Canada 2019 - Introduction to Asynchronous Programming
PyCon Canada 2019 - Introduction to Asynchronous ProgrammingPyCon Canada 2019 - Introduction to Asynchronous Programming
PyCon Canada 2019 - Introduction to Asynchronous Programming
 
Devel::NYTProf v3 - 200908 (OUTDATED, see 201008)
Devel::NYTProf v3 - 200908 (OUTDATED, see 201008)Devel::NYTProf v3 - 200908 (OUTDATED, see 201008)
Devel::NYTProf v3 - 200908 (OUTDATED, see 201008)
 
Erlang factory 2011 london
Erlang factory 2011 londonErlang factory 2011 london
Erlang factory 2011 london
 
Scaling application with RabbitMQ
Scaling application with RabbitMQScaling application with RabbitMQ
Scaling application with RabbitMQ
 
Scaling Ruby with Evented I/O - Ruby underground
Scaling Ruby with Evented I/O - Ruby undergroundScaling Ruby with Evented I/O - Ruby underground
Scaling Ruby with Evented I/O - Ruby underground
 
EhTrace -- RoP Hooks
EhTrace -- RoP HooksEhTrace -- RoP Hooks
EhTrace -- RoP Hooks
 
FunctionalConf '16 Robert Virding Erlang Ecosystem
FunctionalConf '16 Robert Virding Erlang EcosystemFunctionalConf '16 Robert Virding Erlang Ecosystem
FunctionalConf '16 Robert Virding Erlang Ecosystem
 
Clack: glue for web apps
Clack: glue for web appsClack: glue for web apps
Clack: glue for web apps
 
Woo: Writing a fast web server @ ELS2015
Woo: Writing a fast web server @ ELS2015Woo: Writing a fast web server @ ELS2015
Woo: Writing a fast web server @ ELS2015
 
Celery introduction
Celery introductionCelery introduction
Celery introduction
 
Ruby on the JVM
Ruby on the JVMRuby on the JVM
Ruby on the JVM
 

En vedette (6)

Zpátky k lidem
Zpátky k lidemZpátky k lidem
Zpátky k lidem
 
Elastic Search: Beyond Ordinary Fulltext Search (Webexpo 2011 Prague)
Elastic Search: Beyond Ordinary Fulltext Search (Webexpo 2011 Prague)Elastic Search: Beyond Ordinary Fulltext Search (Webexpo 2011 Prague)
Elastic Search: Beyond Ordinary Fulltext Search (Webexpo 2011 Prague)
 
Jakub Nešetřil: Jak (ne)dělat API
Jakub Nešetřil: Jak (ne)dělat APIJakub Nešetřil: Jak (ne)dělat API
Jakub Nešetřil: Jak (ne)dělat API
 
Interaktivita, originalita a návrhové vzory
Interaktivita, originalita a návrhové vzoryInteraktivita, originalita a návrhové vzory
Interaktivita, originalita a návrhové vzory
 
Architektura skalovatelnych aplikaci
Architektura skalovatelnych aplikaciArchitektura skalovatelnych aplikaci
Architektura skalovatelnych aplikaci
 
Narrative Theory
Narrative TheoryNarrative Theory
Narrative Theory
 

Similaire à Cooking a rabbit pie

Real time system_performance_mon
Real time system_performance_monReal time system_performance_mon
Real time system_performance_mon
Tomas Doran
 
Messaging, interoperability and log aggregation - a new framework
Messaging, interoperability and log aggregation - a new frameworkMessaging, interoperability and log aggregation - a new framework
Messaging, interoperability and log aggregation - a new framework
Tomas Doran
 
Lotuscript for large systems
Lotuscript for large systemsLotuscript for large systems
Lotuscript for large systems
Bill Buchan
 
Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640
Newlink
 
Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640
Newlink
 
Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640
LLC NewLink
 
Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640
Newlink
 
Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640
Newlink
 
Gearman - Northeast PHP 2012
Gearman - Northeast PHP 2012Gearman - Northeast PHP 2012
Gearman - Northeast PHP 2012
Mike Willbanks
 

Similaire à Cooking a rabbit pie (20)

Real time system_performance_mon
Real time system_performance_monReal time system_performance_mon
Real time system_performance_mon
 
Messaging, interoperability and log aggregation - a new framework
Messaging, interoperability and log aggregation - a new frameworkMessaging, interoperability and log aggregation - a new framework
Messaging, interoperability and log aggregation - a new framework
 
Puppet Camp New York 2014: Streamlining Puppet Development Workflow
Puppet Camp New York 2014: Streamlining Puppet Development Workflow Puppet Camp New York 2014: Streamlining Puppet Development Workflow
Puppet Camp New York 2014: Streamlining Puppet Development Workflow
 
Lotuscript for large systems
Lotuscript for large systemsLotuscript for large systems
Lotuscript for large systems
 
Treasure Data Summer Internship 2016
Treasure Data Summer Internship 2016Treasure Data Summer Internship 2016
Treasure Data Summer Internship 2016
 
EUC2015 - Load testing XMPP servers with Plain Old Erlang
EUC2015 - Load testing XMPP servers with Plain Old ErlangEUC2015 - Load testing XMPP servers with Plain Old Erlang
EUC2015 - Load testing XMPP servers with Plain Old Erlang
 
Numba Overview
Numba OverviewNumba Overview
Numba Overview
 
Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640
 
Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640
 
Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640
 
Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640
 
Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640Xen and-the-art-of-rails-deployment2640
Xen and-the-art-of-rails-deployment2640
 
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
 
Queick: A Simple Job Queue System for Python
Queick: A Simple Job Queue System for PythonQueick: A Simple Job Queue System for Python
Queick: A Simple Job Queue System for Python
 
John adams talk cloudy
John adams   talk cloudyJohn adams   talk cloudy
John adams talk cloudy
 
Distributed and concurrent programming with RabbitMQ and EventMachine Rails U...
Distributed and concurrent programming with RabbitMQ and EventMachine Rails U...Distributed and concurrent programming with RabbitMQ and EventMachine Rails U...
Distributed and concurrent programming with RabbitMQ and EventMachine Rails U...
 
How we use Twisted in Launchpad
How we use Twisted in LaunchpadHow we use Twisted in Launchpad
How we use Twisted in Launchpad
 
Parallel and Asynchronous Programming - ITProDevConnections 2012 (English)
Parallel and Asynchronous Programming -  ITProDevConnections 2012 (English)Parallel and Asynchronous Programming -  ITProDevConnections 2012 (English)
Parallel and Asynchronous Programming - ITProDevConnections 2012 (English)
 
Gearman - Northeast PHP 2012
Gearman - Northeast PHP 2012Gearman - Northeast PHP 2012
Gearman - Northeast PHP 2012
 
C100 k and go
C100 k and goC100 k and go
C100 k and go
 

Plus de Tomas Doran

Test driven infrastructure development (2 - puppetconf 2013 edition)
Test driven infrastructure development (2 - puppetconf 2013 edition)Test driven infrastructure development (2 - puppetconf 2013 edition)
Test driven infrastructure development (2 - puppetconf 2013 edition)
Tomas Doran
 
London devops logging
London devops loggingLondon devops logging
London devops logging
Tomas Doran
 
Message:Passing - lpw 2012
Message:Passing - lpw 2012Message:Passing - lpw 2012
Message:Passing - lpw 2012
Tomas Doran
 
Webapp security testing
Webapp security testingWebapp security testing
Webapp security testing
Tomas Doran
 
Webapp security testing
Webapp security testingWebapp security testing
Webapp security testing
Tomas Doran
 
High scale flavour
High scale flavourHigh scale flavour
High scale flavour
Tomas Doran
 
Large platform architecture in (mostly) perl - an illustrated tour
Large platform architecture in (mostly) perl - an illustrated tourLarge platform architecture in (mostly) perl - an illustrated tour
Large platform architecture in (mostly) perl - an illustrated tour
Tomas Doran
 

Plus de Tomas Doran (20)

Empowering developers to deploy their own data stores
Empowering developers to deploy their own data storesEmpowering developers to deploy their own data stores
Empowering developers to deploy their own data stores
 
Dockersh and a brief intro to the docker internals
Dockersh and a brief intro to the docker internalsDockersh and a brief intro to the docker internals
Dockersh and a brief intro to the docker internals
 
Sensu and Sensibility - Puppetconf 2014
Sensu and Sensibility - Puppetconf 2014Sensu and Sensibility - Puppetconf 2014
Sensu and Sensibility - Puppetconf 2014
 
Building a smarter application stack - service discovery and wiring for Docker
Building a smarter application stack - service discovery and wiring for DockerBuilding a smarter application stack - service discovery and wiring for Docker
Building a smarter application stack - service discovery and wiring for Docker
 
Chasing AMI - Building Amazon machine images with Puppet, Packer and Jenkins
Chasing AMI - Building Amazon machine images with Puppet, Packer and JenkinsChasing AMI - Building Amazon machine images with Puppet, Packer and Jenkins
Chasing AMI - Building Amazon machine images with Puppet, Packer and Jenkins
 
Deploying puppet code at light speed
Deploying puppet code at light speedDeploying puppet code at light speed
Deploying puppet code at light speed
 
Thinking through puppet code layout
Thinking through puppet code layoutThinking through puppet code layout
Thinking through puppet code layout
 
Docker puppetcamp london 2013
Docker puppetcamp london 2013Docker puppetcamp london 2013
Docker puppetcamp london 2013
 
"The worst code I ever wrote"
"The worst code I ever wrote""The worst code I ever wrote"
"The worst code I ever wrote"
 
Test driven infrastructure development (2 - puppetconf 2013 edition)
Test driven infrastructure development (2 - puppetconf 2013 edition)Test driven infrastructure development (2 - puppetconf 2013 edition)
Test driven infrastructure development (2 - puppetconf 2013 edition)
 
Test driven infrastructure development
Test driven infrastructure developmentTest driven infrastructure development
Test driven infrastructure development
 
London devops - orc
London devops - orcLondon devops - orc
London devops - orc
 
London devops logging
London devops loggingLondon devops logging
London devops logging
 
Message:Passing - lpw 2012
Message:Passing - lpw 2012Message:Passing - lpw 2012
Message:Passing - lpw 2012
 
Webapp security testing
Webapp security testingWebapp security testing
Webapp security testing
 
Webapp security testing
Webapp security testingWebapp security testing
Webapp security testing
 
Dates aghhhh!!?!?!?!
Dates aghhhh!!?!?!?!Dates aghhhh!!?!?!?!
Dates aghhhh!!?!?!?!
 
High scale flavour
High scale flavourHigh scale flavour
High scale flavour
 
Large platform architecture in (mostly) perl - an illustrated tour
Large platform architecture in (mostly) perl - an illustrated tourLarge platform architecture in (mostly) perl - an illustrated tour
Large platform architecture in (mostly) perl - an illustrated tour
 
Large platform architecture in (mostly) perl
Large platform architecture in (mostly) perlLarge platform architecture in (mostly) perl
Large platform architecture in (mostly) perl
 

Dernier

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
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Dernier (20)

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
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
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
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
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)
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
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
 
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
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 

Cooking a rabbit pie

  • 1. Real time system performance monitoring AMQP and CatalystX::JobServer Cooking a Rabbit pie Tomas (t0m) Doran São Paulo.pm perl workshop 2010 London perl workshop 2010
  • 2. I accidentally wrote software • I try to avoid doing this • I’m not very good at it ;)
  • 3. Aka the “my code still doesn’t work yet” talk • This is the 2nd time I’ve talked about AMQP stuff this year. • Half the code still isn’t properly production ready. • It’s an order of magnitude better than last time round ;)
  • 4. Message queueing • Lets not talk about the code just yet... • This talk is about Message Queueing and specifically AMQP. • I’m going to assume if you knew nothing, you went to the earlier talk - not going to duplicate too much.
  • 5. AMQP Concepts RabbitMQ vhost Publisher Exchange Queue Consumer
  • 6. AMQP • 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’
  • 7. Routing keys • Each message sent to an exchange has a routing key. • Each queue can be bound to exchanges with routing keys • I.e. you can subscribe to thingsilike.meat and thingsilike.beer on an exchange, but not subscribe to thingsilike.classicalmusic • Wildcards - # and *
  • 8. AMQP Delivery modes • Two modes of consuming messages • Get - Gets a single message from the queue • Subscribe - server sends messages from the queue to the client until cancelled • Durability - exchange and queue must agree • Explicit ACK possible but not required
  • 9. Non-trivial message queueing • Flexible topologies. • Each queue can bind to multiple exchanges, with multiple routing keys. • Routing can be dynamic. • E.g. one client can ‘tail’ a log, but then re- bind with a different routing key to get a different subset of messages.
  • 10. Custom Exchanges • RabbitMQ allows pluggable exchange types • Simplest and most useful example is the ‘emit last message on bind’ exchange • New consumers get the last message seen on the exchange
  • 11. I wanted to play with RabbitMQ • I blame Net::RabbitFoot • It’s written using AnyEvent • 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
  • 12. 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
  • 14. Ok, there is some setup
  • 15. Ok, there is some setup
  • 16. Dumping them to a file • That’s pretty simple after that.. • Except: • Log rotation • Not flushing to disk once per message • etc...
  • 17. Viewing them live • Someone wrote an AMQP client in flash • AMQP security model not useful publicly • Cute prototype • (Sorry no live demo - it hated me when I tried to make it work again)
  • 18.
  • 19. Queueing Jobs • New skool scripts - MX::Getopt and a - >run method • Add MooseX::Storage • You can flatten a script as JSON, send it over the wire, re-inflate it, call the ->run method.
  • 20. Message Queueing Framework? • I now have several scripts, all doing bits with queuing. All duplicating code. • I want to run batch jobs • I want to aggregate log messages (e.g. average web requests per min). • I want to log messages to file(s) • I want to broadcast (and log) aggregates • Need something more generic
  • 21. Most urgent problem: 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..
  • 22. But wait • Each ‘thing’ (timer, listener, logger, emitter, worker etc) an instance with state in attributes - traits => [‘Serialize’] • Construct a instances from config file. • One process managing each machine’s tasks. • Less processes to manage, win. Working out the state just got harder still, FAIL.
  • 23. But wait • Make all the classes use MooseX::Storage • Catalyst makes instances of things from config... • Build Catalyst app from config file at boot • 2 Trivial controllers introspect entire app • State monitoring (nagios, munin, debugging) now trivial
  • 25. Hubris • I could have just used Gearman for my jobs. • I could have come up with a simpler solution for logging and aggregation. • I was having fun. • Until I tried running it in production.
  • 26. Hubris • I could have just used Gearman for my jobs. • I could have come up with a simpler solution for logging and aggregation. • I was having fun. • Until I tried running it in production.
  • 27. Hubris • I could have just used Gearman for my jobs. • I could have come up with a simpler solution for logging and aggregation. • I was having fun. • It crashed and burned in production. • sys programming, async, pluggable, FUUUU
  • 28. Hubris • I could have just used Gearman for my jobs. • I could have come up with a simpler solution for logging and aggregation. • I was having fun. • It crashed and burned in production. • sys programming, async, pluggable, FUUUU
  • 29. I learnt a lot • I knew a lot in theory before. Doing it is somewhat harder :) • It doesn’t crash any more. • Or leak fds • Still not perfect (e.g. doesn’t reconnect right if mq falls over)
  • 30. Why laziness didn’t win. • Brad’s code is great, until you try not being Livejournal. • My day job is nothing like Livejournal. • I was still very excited about AMQP • I had a talk to write for a conference (and I could avoid writing it by writing software) • Hippie rocked my world
  • 31. Web 2.0 • Lots of Javascript, update pages dynamically • Messages already JSON from MX::Storage • comet - long poll, multipart xhr • Joose.Storage - inflate your objects in Javascript • Present data from message queues to the user as it becomes available. • Hippie - painless comet - rocked my world
  • 32. Web::Hippie • Async pipe to the browser. • Abstracts all the nasty ajax details (also does long poll, or websockets) • Applications (I had a practical use for): • Interactive log tail. Realtime systems graphs. • Instant feedback from long running batch jobs • ‘Social’ features by broadcasting/aggregating data
  • 33. Job Statuses • We inflate JSON data to $job • $job->run($status_cb); • $status_cb->( CompletionEstimate- >new( percent => 50 ) );
  • 34. Job Statuses • All jobs have a UUID • Job statuses - ‘Running/Complete/StatusLine/ CompletionEstimate/RunJob’ • Ask for a pipe to some UUID(s) • Draw nice progress indicators • Further jobs can be included (RunJob magic) • Custom statuses trivial - perl class with attributes, Javascript class with display logic
  • 35. Wait a second • I don’t want the unwashed masses making HTTP connections to machines running jobs. • Ergo: Send all the job statuses to an exchange, use UUID as routing key. • Optional ‘Hippies’ controller - client produces a set of keys, these sprintf => routing keys. • Hippie pipe => one queue per-client queue bound to keys they want. • ‘RunJob’ messages automatically binds extra key, so you see things triggered by things you are watching.
  • 36. How it all hangs together
  • 37. Useable? • Running jobs works. • Running it in production at work. It doesn’t crash any more. • Status pipe stuff not deployed to clients yet. • If you need a high volume, simple, production ready job scheduler, right now, use Gearman.
  • 38. Demo?
  • 39. Demo 1 • Simple job server • Enqueues 10 jobs at start • 1 worker process • JSON status of app • Add workers dynamically
  • 40. Demo 2 • Publish component status to queue regularly • Simple CLI script tailing queue • Jobs indexed by UUID - allows Hippie
  • 41. Demo 3 • Status updates from ‘Job Server’ published. • 2nd ‘/hippies’ process binds queue to exchange for some UUIDs. • Gets ‘RunJob’ notifications, and statuses when they run.
  • 42. Next steps? • Reliability - recover from errors better. • Expose more stats about MQ use. • Better (some!) logging. • Docs would be good... • Hippe::Pipe for bidirectional • More traits / plugins / components • More / better stock Javascript
  • 43. What to go look at • http://www.rabbitmq.com • Docs, setup info, FAQ • Slideshare - lots of good and more detailed AMQP introductions.
  • 44. What to go look at (CPAN) • Net::RabbitFoot • App::RabbitTail • Plack / Twiggy • Web::Hippie • CatalystX::JobServer (github.com/bobtfish/ CatalystX-JobServer)
  • 45. Other solutions • Gearman • STOMP • ActiveMQ (or Rabbit has a STOMP adaptor - good luck) • Catalyst::Engine::STOMP
  • 46. Thanks! • Questions? • Anyone interested in playing, feel free to grab me on irc (t0m @ magnet & Freenode) • Happy to hand-hold as I need more people using this. • I’ll love you forever if you write docs.

Notes de l'éditeur

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n