SlideShare a Scribd company logo
1 of 36
High scale flavor
(recipes for message
      queueing)

             Tomas (t0m) Doran
                London Perl
              Workshop 2010
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.
What is the problem
  with web apps?
• App servers take a lot of RAM
• Context switching expensive
• A lot of apps think like a CGI.
• Making the user wait IS HORRIBLE.
• Anything but very fast pages is fail.
One page request per CPU core
   Even if extra context switching has zero overhead
    you serve people sooner if you queue requests.

       A     B       A   B     A     B       A   B

                 A                       B

  A finishes significantly before B in the lower diagram
            B finishes at the same time in both
N.B. This explicitly assumes you never wait on external IO
                       (e.g. a database)
What are the solutions
• Use a PAL (Page Assembly Layer) - e.g.
  Varnish
• Defer doing work inside the web request
  to a queue
• AJAX (heavy javascript) apps making many
  requests make this even more important.
• If your requests are all small and fast then
  you can win by doing multiple small
  requests rather than one expensive one
Message queueing

• Many many flavors.
 • Going to cover options available right
     now in perl
• First, a little theory
Messaging Topologies
• I.e. how producers and consumers interact
  together through the message broker
• 3 common patterns - considerably more
  complex applications possible.
• Even within these there is additional
  complexity to consider, e.g. message
  durability.
1: Publish-Subscribe
• ‘Topic’ in ActiveMQ
• Anonymous queues in AMQP
• One (or more) publishers
• Zero (or more) consumers
• Every consumer gets every message
• Messages discarded if no consumers
• E.g. log message listener(s)
2: Queue(s)
• One or more producers
• One or more consumers
• Each message delivered to exactly one
  consumer
• Messages ‘queued’ (possibly to disk)
• E.g. Job queue with worker pool allowing
  you to work efficiently through high load
  spikes
3: Request / Response

• Create anonymous queue for replies
• Publish to well known queue(s), include
  return address
• Wait for reply.
• Arrange for messages to be discarded if
  you stop listening for the reply.
STOMP
• Streamed Text Oriented Messageing
  Protocol
• Simple. Interoperable.
• You probably want to use ActiveMQ
• Net::STOMP
• Simple semantics: Queues and Topics
• You can build the 3 simple patterns from
  these
ActiveMQ - Topics
• Publish / subscribe semantics.
• Message goes to all the subscribers
• Zero or more subscribers
• Messages thrown away if no subscribers
• Safe (cannot fill up server with undelivered
  messages)
ActiveMQ - Queues
• Load balancer semantics.
• Each message - 1 consumer.
• Messages queued.
• Multiple consumers
• Ack required (auto-ack possible)
• Danger will robinson!
AMQP
• More complex than STOMP
• Wiring of message routing is part of the
  protocol.
• All your clients know (at least half) of the
  wiring.
• Different topologies depending on routing
  configuration.
• 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 (forces all queues attached
  to be durable)
Queues
• Queues can be named.
• Queues are bound to one (or more)
  exchanges.
• Queues can have 0 or more clients
• Queues may persist or be deleted when
  they have no clients
• FIFO (if you have 1 consumer)
• Message never delivered to > 1 client
Bindings
• Binding is what joins a queue and an
  exchange.
• There can be more than one binding for
  each queue, allowing a single consumer to
  listen to multiple message sources
• You can bind to topic exchanges selectively
  via the message ‘routing key’
Job queue
• Named exchange
• Bound to 1 named and persistent queue
• 0 or more listeners get round-robin
  messages
• Messages queue when nobody listens / if
  consumers are slow
Publish/Subscribe
• Named exchange
• Each client creates an anonymous
  ephemeral queue
• Client binds the queue to that exchange
• All clients get all messages
• Messages go to /dev/null if no clients
AMQP can be complex
• Different exchange types - direct, topic,
  fanout (and custom exchange types
  possible)
• Messages have a routing key allowing
  selective binding.
• You can do a lot using these and a mix of
  named and anonymous queues
• Much more complex topologies possible
Implementations:

• So - I want a queue
• What do I use?
 • Naive approaches
 • Job queue only approaches
 • More sophisticated/custom approaches
(Shared) database table
• Have a ‘jobs’ table, with some data, and a
  ‘status’ column.
• Waiting => Running => Done
• Job workers poll the table and change
  statuses.
• NO NO NO NO NO NO NO NO
• No, really, mst will come and break your
  legs if you do this (after he stops laughing)
(Shared) database table
• Have a ‘jobs’ table, with some data, and a
  ‘status’ column.
• Waiting => Running => Done
• Job workers poll the table and change
  statuses.
• NO NO NO NO NO NO NO NO
• No, really, mst will come and break your
  legs if you do this.
(Shared) database table
• Have a ‘jobs’ table, with some data, and a
  ‘status’ column.
• Waiting => Running => Done
• MySQL will get the query plan wrong if
  you try joining this table (hint: the
  cardinality on your status column is 3).
• You will lose super-hard. HAND.
(Queue) database table

• Have separate queued / running / done tables
• Less bad for performance - at least the ‘find
  something to do’ query is very cheap.
• Still pretty terrible.
• You still re-invented a big old wheel here,
  probably badly.
Gearman
• Around since 2006. Multi platform.
• Not really a message queue - designed as a
  job queuing system
• Client, Job Server, Worker
• Failover (multiple job servers)
• NOT persistent
• Simple, works well (if that’s all you need)
TheSchwartz
• Is Persistent
• From the same place as Gearman
• Not as well adopted
• Relies on a MySQL database - SPOF
• Still simple - maybe the easiest way to get
  started (if you need reliable)?
Client libs: Net::Stomp
• Apache ActiveMQ.
• Dead simple producers and consumers.
• Just a client - you need to manage / run
  your own jobs.
• Blocking.
• Works perfectly well for sending messages
  from a web app.
Client libs:
      Net::RabbitFoot
• AMQP / RabbitMQ
• AnyEvent based - non blocking.
• Documentation pretty poor (sorry).
• Works well if you have an async app.
• Can be used inside a web app for simple
  sending.
Catalyst::Engine::Stomp
•   By chrisa @ Venda & yours truly; now
    maintained by Paul Moony.
•   Simple framework for writing jobs / managing
    workers.
•   Allows you to fire and forget, or fire and wait
    for termination (and pass a message back)
•   Achieves many of the same things a Gearman
•   Used in anger by several companies.
         (http://miltonkeynes.pm.org/talks/2010/06/paul_mooney_stomp_moosex_workers.pdf)
Net::ActiveMQ

• Builds on Catalyst::Engine::STOMP
• Chisel talked about this at YAPC::EU (Friday
  PM ‘Going Postal’)
• NetAPorter people - poke him to release it
  (or at least put it on github)!
Web::Hippie
• Persistent (potentially bidirectional) web
  pipe to applications.
• Cheap connection, no polling needed (on
  reasonably modern browsers). Great as the
  listener part for ‘replies’
• Downsides - needs to be async - no DBI
  (kinda)!
• Plays very nicely with RabbitMQ (hint
  MooseX::Storage & Joose.Storage <3)
CatalystX::JobServer
• My current baby.
• Uses AMQP.
• Provides Web::Hippie pipes for jobs - shiny
  shiny ajax updates.
• Barely production ready (but useable).
• I’m talking about it later...
Conclusions
• Use JSON for your message payloads.
• You probably want to use Gearman if you
  can get away with it.
• STOMP works well and is simple, tried and
  tested jobs solution.
• AMQP is nicer and more flexible, but there
  are less proven solutions (in perl).

More Related Content

What's hot

Message queue architecture
Message queue architectureMessage queue architecture
Message queue architectureMajdee Zoabi
 
Windows Azure Service Bus
Windows Azure Service BusWindows Azure Service Bus
Windows Azure Service BusPavel Revenkov
 
Ups and downs of enterprise Java app in a research setting
Ups and downs of enterprise Java app in a research settingUps and downs of enterprise Java app in a research setting
Ups and downs of enterprise Java app in a research settingCsaba Toth
 
Zarafa SummerCamp 2012 - Exchange Web Services on Zarafa
Zarafa SummerCamp 2012 - Exchange Web Services on ZarafaZarafa SummerCamp 2012 - Exchange Web Services on Zarafa
Zarafa SummerCamp 2012 - Exchange Web Services on ZarafaZarafa
 
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)Panagiotis Kanavos
 
ActiveMQ In Action - ApacheCon 2011
ActiveMQ In Action - ApacheCon 2011ActiveMQ In Action - ApacheCon 2011
ActiveMQ In Action - ApacheCon 2011Bruce Snyder
 
Flink Forward SF 2017: Tzu-Li (Gordon) Tai - Joining the Scurry of Squirrels...
Flink Forward SF 2017: Tzu-Li (Gordon) Tai -  Joining the Scurry of Squirrels...Flink Forward SF 2017: Tzu-Li (Gordon) Tai -  Joining the Scurry of Squirrels...
Flink Forward SF 2017: Tzu-Li (Gordon) Tai - Joining the Scurry of Squirrels...Flink Forward
 
Discover the Capabilities of Windows Azure Service Bus to Power Agile Busines...
Discover the Capabilities of Windows Azure Service Bus to Power Agile Busines...Discover the Capabilities of Windows Azure Service Bus to Power Agile Busines...
Discover the Capabilities of Windows Azure Service Bus to Power Agile Busines...Sergio Compean
 
10 things, an Oracle DBA should care about when moving to PostgreSQL
10 things, an Oracle DBA should care about when moving to PostgreSQL10 things, an Oracle DBA should care about when moving to PostgreSQL
10 things, an Oracle DBA should care about when moving to PostgreSQLPostgreSQL-Consulting
 
Apache ActiveMQ - Enterprise messaging in action
Apache ActiveMQ - Enterprise messaging in actionApache ActiveMQ - Enterprise messaging in action
Apache ActiveMQ - Enterprise messaging in actiondejanb
 
Archipel Introduction - ejabberd SF Meetup
Archipel Introduction - ejabberd SF MeetupArchipel Introduction - ejabberd SF Meetup
Archipel Introduction - ejabberd SF MeetupMickaël Rémond
 
Serve like a boss (part one)
Serve like a boss (part one)Serve like a boss (part one)
Serve like a boss (part one)Hamed Nemati
 
Transactional Streaming: If you can compute it, you can probably stream it.
Transactional Streaming: If you can compute it, you can probably stream it.Transactional Streaming: If you can compute it, you can probably stream it.
Transactional Streaming: If you can compute it, you can probably stream it.jhugg
 
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 frameworkTomas Doran
 
Cloud Messaging Service: Technical Overview
Cloud Messaging Service: Technical OverviewCloud Messaging Service: Technical Overview
Cloud Messaging Service: Technical OverviewMessaging Meetup
 
Where do I put this data? #lessql
Where do I put this data? #lessqlWhere do I put this data? #lessql
Where do I put this data? #lessqlEzra Zygmuntowicz
 
Apache con2016final
Apache con2016final Apache con2016final
Apache con2016final Salesforce
 
Multiply like rabbits with rabbit mq
Multiply like rabbits with rabbit mqMultiply like rabbits with rabbit mq
Multiply like rabbits with rabbit mqColdFusionConference
 

What's hot (20)

Message queue architecture
Message queue architectureMessage queue architecture
Message queue architecture
 
3 years with Clojure
3 years with Clojure3 years with Clojure
3 years with Clojure
 
Windows Azure Service Bus
Windows Azure Service BusWindows Azure Service Bus
Windows Azure Service Bus
 
Ups and downs of enterprise Java app in a research setting
Ups and downs of enterprise Java app in a research settingUps and downs of enterprise Java app in a research setting
Ups and downs of enterprise Java app in a research setting
 
Zarafa SummerCamp 2012 - Exchange Web Services on Zarafa
Zarafa SummerCamp 2012 - Exchange Web Services on ZarafaZarafa SummerCamp 2012 - Exchange Web Services on Zarafa
Zarafa SummerCamp 2012 - Exchange Web Services on Zarafa
 
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)
 
ActiveMQ In Action - ApacheCon 2011
ActiveMQ In Action - ApacheCon 2011ActiveMQ In Action - ApacheCon 2011
ActiveMQ In Action - ApacheCon 2011
 
Flink Forward SF 2017: Tzu-Li (Gordon) Tai - Joining the Scurry of Squirrels...
Flink Forward SF 2017: Tzu-Li (Gordon) Tai -  Joining the Scurry of Squirrels...Flink Forward SF 2017: Tzu-Li (Gordon) Tai -  Joining the Scurry of Squirrels...
Flink Forward SF 2017: Tzu-Li (Gordon) Tai - Joining the Scurry of Squirrels...
 
Discover the Capabilities of Windows Azure Service Bus to Power Agile Busines...
Discover the Capabilities of Windows Azure Service Bus to Power Agile Busines...Discover the Capabilities of Windows Azure Service Bus to Power Agile Busines...
Discover the Capabilities of Windows Azure Service Bus to Power Agile Busines...
 
10 things, an Oracle DBA should care about when moving to PostgreSQL
10 things, an Oracle DBA should care about when moving to PostgreSQL10 things, an Oracle DBA should care about when moving to PostgreSQL
10 things, an Oracle DBA should care about when moving to PostgreSQL
 
Apache ActiveMQ - Enterprise messaging in action
Apache ActiveMQ - Enterprise messaging in actionApache ActiveMQ - Enterprise messaging in action
Apache ActiveMQ - Enterprise messaging in action
 
Archipel Introduction - ejabberd SF Meetup
Archipel Introduction - ejabberd SF MeetupArchipel Introduction - ejabberd SF Meetup
Archipel Introduction - ejabberd SF Meetup
 
Serve like a boss (part one)
Serve like a boss (part one)Serve like a boss (part one)
Serve like a boss (part one)
 
Transactional Streaming: If you can compute it, you can probably stream it.
Transactional Streaming: If you can compute it, you can probably stream it.Transactional Streaming: If you can compute it, you can probably stream it.
Transactional Streaming: If you can compute it, you can probably stream it.
 
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
 
Cloud Messaging Service: Technical Overview
Cloud Messaging Service: Technical OverviewCloud Messaging Service: Technical Overview
Cloud Messaging Service: Technical Overview
 
Where do I put this data? #lessql
Where do I put this data? #lessqlWhere do I put this data? #lessql
Where do I put this data? #lessql
 
Apache con2016final
Apache con2016final Apache con2016final
Apache con2016final
 
Multiply like rabbits with rabbit mq
Multiply like rabbits with rabbit mqMultiply like rabbits with rabbit mq
Multiply like rabbits with rabbit mq
 
Mini-Training: Message Brokers
Mini-Training: Message BrokersMini-Training: Message Brokers
Mini-Training: Message Brokers
 

Similar to High scale flavour

Real time system_performance_mon
Real time system_performance_monReal time system_performance_mon
Real time system_performance_monTomas Doran
 
Building an Event Bus at Scale
Building an Event Bus at ScaleBuilding an Event Bus at Scale
Building an Event Bus at Scalejimriecken
 
Eventual Consistency @WalmartLabs with Kafka, Avro, SolrCloud and Hadoop
Eventual Consistency @WalmartLabs with Kafka, Avro, SolrCloud and HadoopEventual Consistency @WalmartLabs with Kafka, Avro, SolrCloud and Hadoop
Eventual Consistency @WalmartLabs with Kafka, Avro, SolrCloud and HadoopAyon Sinha
 
Building Big Data Streaming Architectures
Building Big Data Streaming ArchitecturesBuilding Big Data Streaming Architectures
Building Big Data Streaming ArchitecturesDavid Martínez Rego
 
Putting Kafka Into Overdrive
Putting Kafka Into OverdrivePutting Kafka Into Overdrive
Putting Kafka Into OverdriveTodd Palino
 
Enterprise Messaging with RabbitMQ.pdf
Enterprise Messaging with RabbitMQ.pdfEnterprise Messaging with RabbitMQ.pdf
Enterprise Messaging with RabbitMQ.pdfOrtus Solutions, Corp
 
Modern Distributed Messaging and RPC
Modern Distributed Messaging and RPCModern Distributed Messaging and RPC
Modern Distributed Messaging and RPCMax Alexejev
 
Select Stars: A DBA's Guide to Azure Cosmos DB (SQL Saturday Oslo 2018)
Select Stars: A DBA's Guide to Azure Cosmos DB (SQL Saturday Oslo 2018)Select Stars: A DBA's Guide to Azure Cosmos DB (SQL Saturday Oslo 2018)
Select Stars: A DBA's Guide to Azure Cosmos DB (SQL Saturday Oslo 2018)Bob Pusateri
 
Multi-platform Enterprise Messaging with RabbitMQ
Multi-platform Enterprise Messaging with RabbitMQMulti-platform Enterprise Messaging with RabbitMQ
Multi-platform Enterprise Messaging with RabbitMQOrtus Solutions, Corp
 
Jay Kreps on Project Voldemort Scaling Simple Storage At LinkedIn
Jay Kreps on Project Voldemort Scaling Simple Storage At LinkedInJay Kreps on Project Voldemort Scaling Simple Storage At LinkedIn
Jay Kreps on Project Voldemort Scaling Simple Storage At LinkedInLinkedIn
 
Message:Passing - lpw 2012
Message:Passing - lpw 2012Message:Passing - lpw 2012
Message:Passing - lpw 2012Tomas Doran
 
Cooking a rabbit pie
Cooking a rabbit pieCooking a rabbit pie
Cooking a rabbit pieTomas Doran
 
Multiply like rabbits with rabbit mq
Multiply like rabbits with rabbit mqMultiply like rabbits with rabbit mq
Multiply like rabbits with rabbit mqdevObjective
 
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-deployment2640Newlink
 
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-deployment2640LLC 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-deployment2640Newlink
 
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-deployment2640Newlink
 

Similar to High scale flavour (20)

Real time system_performance_mon
Real time system_performance_monReal time system_performance_mon
Real time system_performance_mon
 
Building an Event Bus at Scale
Building an Event Bus at ScaleBuilding an Event Bus at Scale
Building an Event Bus at Scale
 
Eventual Consistency @WalmartLabs with Kafka, Avro, SolrCloud and Hadoop
Eventual Consistency @WalmartLabs with Kafka, Avro, SolrCloud and HadoopEventual Consistency @WalmartLabs with Kafka, Avro, SolrCloud and Hadoop
Eventual Consistency @WalmartLabs with Kafka, Avro, SolrCloud and Hadoop
 
Building Big Data Streaming Architectures
Building Big Data Streaming ArchitecturesBuilding Big Data Streaming Architectures
Building Big Data Streaming Architectures
 
Putting Kafka Into Overdrive
Putting Kafka Into OverdrivePutting Kafka Into Overdrive
Putting Kafka Into Overdrive
 
Enterprise Messaging with RabbitMQ.pdf
Enterprise Messaging with RabbitMQ.pdfEnterprise Messaging with RabbitMQ.pdf
Enterprise Messaging with RabbitMQ.pdf
 
Modern Distributed Messaging and RPC
Modern Distributed Messaging and RPCModern Distributed Messaging and RPC
Modern Distributed Messaging and RPC
 
Select Stars: A DBA's Guide to Azure Cosmos DB (SQL Saturday Oslo 2018)
Select Stars: A DBA's Guide to Azure Cosmos DB (SQL Saturday Oslo 2018)Select Stars: A DBA's Guide to Azure Cosmos DB (SQL Saturday Oslo 2018)
Select Stars: A DBA's Guide to Azure Cosmos DB (SQL Saturday Oslo 2018)
 
Multi-platform Enterprise Messaging with RabbitMQ
Multi-platform Enterprise Messaging with RabbitMQMulti-platform Enterprise Messaging with RabbitMQ
Multi-platform Enterprise Messaging with RabbitMQ
 
Jay Kreps on Project Voldemort Scaling Simple Storage At LinkedIn
Jay Kreps on Project Voldemort Scaling Simple Storage At LinkedInJay Kreps on Project Voldemort Scaling Simple Storage At LinkedIn
Jay Kreps on Project Voldemort Scaling Simple Storage At LinkedIn
 
Message:Passing - lpw 2012
Message:Passing - lpw 2012Message:Passing - lpw 2012
Message:Passing - lpw 2012
 
Cooking a rabbit pie
Cooking a rabbit pieCooking a rabbit pie
Cooking a rabbit pie
 
Kafka at scale facebook israel
Kafka at scale   facebook israelKafka at scale   facebook israel
Kafka at scale facebook israel
 
Voldemort Nosql
Voldemort NosqlVoldemort Nosql
Voldemort Nosql
 
Kafka tutorial
Kafka tutorialKafka tutorial
Kafka tutorial
 
Multiply like rabbits with rabbit mq
Multiply like rabbits with rabbit mqMultiply like rabbits with rabbit mq
Multiply like rabbits with rabbit mq
 
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
 

More from Tomas Doran

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 storesTomas Doran
 
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 internalsTomas Doran
 
Sensu and Sensibility - Puppetconf 2014
Sensu and Sensibility - Puppetconf 2014Sensu and Sensibility - Puppetconf 2014
Sensu and Sensibility - Puppetconf 2014Tomas Doran
 
Steamlining your puppet development workflow
Steamlining your puppet development workflowSteamlining your puppet development workflow
Steamlining your puppet development workflowTomas Doran
 
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 DockerTomas Doran
 
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 JenkinsTomas Doran
 
Deploying puppet code at light speed
Deploying puppet code at light speedDeploying puppet code at light speed
Deploying puppet code at light speedTomas Doran
 
Thinking through puppet code layout
Thinking through puppet code layoutThinking through puppet code layout
Thinking through puppet code layoutTomas Doran
 
Docker puppetcamp london 2013
Docker puppetcamp london 2013Docker puppetcamp london 2013
Docker puppetcamp london 2013Tomas Doran
 
"The worst code I ever wrote"
"The worst code I ever wrote""The worst code I ever wrote"
"The worst code I ever wrote"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
 
Test driven infrastructure development
Test driven infrastructure developmentTest driven infrastructure development
Test driven infrastructure developmentTomas Doran
 
London devops - orc
London devops - orcLondon devops - orc
London devops - orcTomas Doran
 
London devops logging
London devops loggingLondon devops logging
London devops loggingTomas Doran
 
Webapp security testing
Webapp security testingWebapp security testing
Webapp security testingTomas Doran
 
Webapp security testing
Webapp security testingWebapp security testing
Webapp security testingTomas Doran
 
Dates aghhhh!!?!?!?!
Dates aghhhh!!?!?!?!Dates aghhhh!!?!?!?!
Dates aghhhh!!?!?!?!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 tourTomas Doran
 
Large platform architecture in (mostly) perl
Large platform architecture in (mostly) perlLarge platform architecture in (mostly) perl
Large platform architecture in (mostly) perlTomas Doran
 

More from 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
 
Steamlining your puppet development workflow
Steamlining your puppet development workflowSteamlining your puppet development workflow
Steamlining your puppet development workflow
 
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
 
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!!?!?!?!
 
Zero mq logs
Zero mq logsZero mq logs
Zero mq logs
 
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
 

Recently uploaded

"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 

Recently uploaded (20)

"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 

High scale flavour

  • 1. High scale flavor (recipes for message queueing) Tomas (t0m) Doran London Perl Workshop 2010
  • 2. 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
  • 3. 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.
  • 4. What is the problem with web apps? • App servers take a lot of RAM • Context switching expensive • A lot of apps think like a CGI. • Making the user wait IS HORRIBLE. • Anything but very fast pages is fail.
  • 5. One page request per CPU core Even if extra context switching has zero overhead you serve people sooner if you queue requests. A B A B A B A B A B A finishes significantly before B in the lower diagram B finishes at the same time in both N.B. This explicitly assumes you never wait on external IO (e.g. a database)
  • 6. What are the solutions • Use a PAL (Page Assembly Layer) - e.g. Varnish • Defer doing work inside the web request to a queue • AJAX (heavy javascript) apps making many requests make this even more important. • If your requests are all small and fast then you can win by doing multiple small requests rather than one expensive one
  • 7. Message queueing • Many many flavors. • Going to cover options available right now in perl • First, a little theory
  • 8. Messaging Topologies • I.e. how producers and consumers interact together through the message broker • 3 common patterns - considerably more complex applications possible. • Even within these there is additional complexity to consider, e.g. message durability.
  • 9. 1: Publish-Subscribe • ‘Topic’ in ActiveMQ • Anonymous queues in AMQP • One (or more) publishers • Zero (or more) consumers • Every consumer gets every message • Messages discarded if no consumers • E.g. log message listener(s)
  • 10. 2: Queue(s) • One or more producers • One or more consumers • Each message delivered to exactly one consumer • Messages ‘queued’ (possibly to disk) • E.g. Job queue with worker pool allowing you to work efficiently through high load spikes
  • 11. 3: Request / Response • Create anonymous queue for replies • Publish to well known queue(s), include return address • Wait for reply. • Arrange for messages to be discarded if you stop listening for the reply.
  • 12. STOMP • Streamed Text Oriented Messageing Protocol • Simple. Interoperable. • You probably want to use ActiveMQ • Net::STOMP • Simple semantics: Queues and Topics • You can build the 3 simple patterns from these
  • 13. ActiveMQ - Topics • Publish / subscribe semantics. • Message goes to all the subscribers • Zero or more subscribers • Messages thrown away if no subscribers • Safe (cannot fill up server with undelivered messages)
  • 14. ActiveMQ - Queues • Load balancer semantics. • Each message - 1 consumer. • Messages queued. • Multiple consumers • Ack required (auto-ack possible) • Danger will robinson!
  • 15. AMQP • More complex than STOMP • Wiring of message routing is part of the protocol. • All your clients know (at least half) of the wiring. • Different topologies depending on routing configuration. • Nice when your server dies - no ‘current config’
  • 16. AMQP Concepts RabbitMQ vhost Publisher Exchange Queue Consumer
  • 17. Concepts - Exchanges • Named • Messages are published (sent) to one exchange • Can be durable (forces all queues attached to be durable)
  • 18. Queues • Queues can be named. • Queues are bound to one (or more) exchanges. • Queues can have 0 or more clients • Queues may persist or be deleted when they have no clients • FIFO (if you have 1 consumer) • Message never delivered to > 1 client
  • 19. Bindings • Binding is what joins a queue and an exchange. • There can be more than one binding for each queue, allowing a single consumer to listen to multiple message sources • You can bind to topic exchanges selectively via the message ‘routing key’
  • 20. Job queue • Named exchange • Bound to 1 named and persistent queue • 0 or more listeners get round-robin messages • Messages queue when nobody listens / if consumers are slow
  • 21. Publish/Subscribe • Named exchange • Each client creates an anonymous ephemeral queue • Client binds the queue to that exchange • All clients get all messages • Messages go to /dev/null if no clients
  • 22. AMQP can be complex • Different exchange types - direct, topic, fanout (and custom exchange types possible) • Messages have a routing key allowing selective binding. • You can do a lot using these and a mix of named and anonymous queues • Much more complex topologies possible
  • 23. Implementations: • So - I want a queue • What do I use? • Naive approaches • Job queue only approaches • More sophisticated/custom approaches
  • 24. (Shared) database table • Have a ‘jobs’ table, with some data, and a ‘status’ column. • Waiting => Running => Done • Job workers poll the table and change statuses. • NO NO NO NO NO NO NO NO • No, really, mst will come and break your legs if you do this (after he stops laughing)
  • 25. (Shared) database table • Have a ‘jobs’ table, with some data, and a ‘status’ column. • Waiting => Running => Done • Job workers poll the table and change statuses. • NO NO NO NO NO NO NO NO • No, really, mst will come and break your legs if you do this.
  • 26. (Shared) database table • Have a ‘jobs’ table, with some data, and a ‘status’ column. • Waiting => Running => Done • MySQL will get the query plan wrong if you try joining this table (hint: the cardinality on your status column is 3). • You will lose super-hard. HAND.
  • 27. (Queue) database table • Have separate queued / running / done tables • Less bad for performance - at least the ‘find something to do’ query is very cheap. • Still pretty terrible. • You still re-invented a big old wheel here, probably badly.
  • 28. Gearman • Around since 2006. Multi platform. • Not really a message queue - designed as a job queuing system • Client, Job Server, Worker • Failover (multiple job servers) • NOT persistent • Simple, works well (if that’s all you need)
  • 29. TheSchwartz • Is Persistent • From the same place as Gearman • Not as well adopted • Relies on a MySQL database - SPOF • Still simple - maybe the easiest way to get started (if you need reliable)?
  • 30. Client libs: Net::Stomp • Apache ActiveMQ. • Dead simple producers and consumers. • Just a client - you need to manage / run your own jobs. • Blocking. • Works perfectly well for sending messages from a web app.
  • 31. Client libs: Net::RabbitFoot • AMQP / RabbitMQ • AnyEvent based - non blocking. • Documentation pretty poor (sorry). • Works well if you have an async app. • Can be used inside a web app for simple sending.
  • 32. Catalyst::Engine::Stomp • By chrisa @ Venda & yours truly; now maintained by Paul Moony. • Simple framework for writing jobs / managing workers. • Allows you to fire and forget, or fire and wait for termination (and pass a message back) • Achieves many of the same things a Gearman • Used in anger by several companies. (http://miltonkeynes.pm.org/talks/2010/06/paul_mooney_stomp_moosex_workers.pdf)
  • 33. Net::ActiveMQ • Builds on Catalyst::Engine::STOMP • Chisel talked about this at YAPC::EU (Friday PM ‘Going Postal’) • NetAPorter people - poke him to release it (or at least put it on github)!
  • 34. Web::Hippie • Persistent (potentially bidirectional) web pipe to applications. • Cheap connection, no polling needed (on reasonably modern browsers). Great as the listener part for ‘replies’ • Downsides - needs to be async - no DBI (kinda)! • Plays very nicely with RabbitMQ (hint MooseX::Storage & Joose.Storage <3)
  • 35. CatalystX::JobServer • My current baby. • Uses AMQP. • Provides Web::Hippie pipes for jobs - shiny shiny ajax updates. • Barely production ready (but useable). • I’m talking about it later...
  • 36. Conclusions • Use JSON for your message payloads. • You probably want to use Gearman if you can get away with it. • STOMP works well and is simple, tried and tested jobs solution. • AMQP is nicer and more flexible, but there are less proven solutions (in perl).

Editor's Notes

  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