SlideShare a Scribd company logo
Martin Tajur
CTO, Co-Founder
February 16, 2016
DevClub XLIII meetup, Tallinn, Estonia
Hello.
● Web-based CRM for small teams with big ambitions.
● Web-based CRM for small teams with big ambitions.
● Founded in 2010.
● Web-based CRM for small teams with big ambitions.
● Founded in 2010.
● Used by over 30,000 businesses worldwide.
● Web-based CRM for small teams with big ambitions.
● Founded in 2010.
● Used by over 30,000 businesses worldwide.
● 140+ employees, venture funded (BVP, Series A in 2015)
● Web-based CRM for small teams with big ambitions.
● Founded in 2010.
● Used by over 30,000 businesses worldwide.
● 140+ employees, venture funded (BVP, Series A in 2015)
● Engineering, Product, UX, Marketing in Tallinn and Tartu.
Marketing, BizDev in New York, NY.
● Web-based CRM for small teams with big ambitions.
● Founded in 2010.
● Used by over 30,000 businesses worldwide.
● 140+ employees, venture funded (BVP, Series A in 2015)
● Engineering, Product, UX, Marketing in Tallinn and Tartu.
Marketing, BizDev in New York, NY.
● Very end user focused, helping the actual sales person do
their job.
Queues queues queues — How RabbitMQ enables reactive architectures
● 20,000+ simultaneous online users
● 20,000+ simultaneous online users
● 800+ API req/sec
● 20,000+ simultaneous online users
● 800+ API req/sec
● 400,000+ incoming emails per day
● 20,000+ simultaneous online users
● 800+ API req/sec
● 400,000+ incoming emails per day
● Started with Node.js based microservices, reactive
architecture in 2012
● 20,000+ simultaneous online users
● 800+ API req/sec
● 400,000+ incoming emails per day
● Started with Node.js based microservices, reactive
architecture in 2012
● In production with first Docker based services
● 20,000+ simultaneous online users
● 800+ API req/sec
● 400,000+ incoming emails per day
● Started with Node.js based microservices, reactive
architecture in 2012
● In production with first Docker based services
● In total, 500+ VMs/hosts/instances
Queues queues queues — How RabbitMQ enables reactive architectures
Queues queues queues — How RabbitMQ enables reactive architectures
Queues queues queues — How RabbitMQ enables reactive architectures
Queues, queues, queues
How RabbitMQ enables reactive architectures
Martin Tajur
CTO, Co-Founder
February 16, 2016
DevClub XLIII meetup, Tallinn, Estonia
➔ Co-Founder and CTO of Pipedrive.
➔ Started career in 2001 as a designer, later a full stack dev.
➔ Part of ex-Skype mafia
About me
Reactive
architectures
The
Reactive
Manifesto
Queues queues queues — How RabbitMQ enables reactive architectures
Manifestos are good when
➔ they are used as building blocks
➔ they add, rather than compete or subtract
➔ they tap into the growing wisdom, and extend it
Queues queues queues — How RabbitMQ enables reactive architectures
Ok, so,
the reactive
manifesto...
An initiative to define a
tech agnostic shared
vocabulary of
architectural patterns for
reactive systems.
It states that...
Systems should be reactive to
Systems should be reactive to
Events
Systems should be reactive to
Events Load
Systems should be reactive to
Events Load
Failure
Systems should be reactive to
Events Load
Failure Users
Systems should be reactive to tolerate
Events Load
Failure Users
Responsive
React to users in
timely manner
http://www.slideshare.net/RezaSamee/the-reactive-manifesto-49897385
Goal
Responsive
React to users in
timely manner
Resilient
React to failures
Elastic
React to load
http://www.slideshare.net/RezaSamee/the-reactive-manifesto-49897385
Goal
Principles
Responsive
React to users in
timely manner
Resilient
React to failures
Elastic
React to load
Message-driven
Component-to-component interaction
http://www.slideshare.net/RezaSamee/the-reactive-manifesto-49897385
Goal
Principles
Method
Systems built as Reactive
Systems are more flexible,
loosely-coupled and
scalable.
This makes them
easier to develop and
amenable to change.
They are significantly more
tolerant of failure and
when failure does occur
they meet it with elegance
rather than disaster.
Reactive Systems are
highly responsive, giving
users effective interactive
feedback.
How queues fit in to
the picture?
10 benefits of
using message
queues
Decoupling
Redundancy
Load Balancing,
Scalability
Elasticity &
Spikability
Resiliency
Delivery Guarantees
Ordering
Guarantees
Buffering
Data Flow
visibility
Asynchronous
communication
http://www.iron.io/top-10-uses-for-message-queue/
10 benefits of
using message
queues
Decoupling
Redundancy
Load Balancing,
Scalability
Elasticity &
Spikability
Resiliency
Delivery Guarantees
Ordering
Guarantees
Buffering
Data Flow
visibility
Asynchronous
communication
Decoupling
➔ Hard to predict future needs at the start of a project.
➔ Message queues create an implicit, data-based interface
that different services can implement.
➔ Allows you to extend and modify processes independently,
ensuring they adhere to the same interfaces.
➔ Lets you swap, mix and add queue consuming services.
10 benefits of
using message
queues
Decoupling
Redundancy
Load Balancing,
Scalability
Elasticity &
Spikability
Resiliency
Delivery Guarantees
Ordering
Guarantees
Buffering
Data Flow
visibility
Asynchronous
communication
10 benefits of
using message
queues
Decoupling
Redundancy
Load Balancing,
Scalability
Elasticity &
Spikability
Resiliency
Delivery Guarantees
Ordering
Guarantees
Buffering
Data Flow
visibility
Asynchronous
communication
Redundancy
➔ Sometimes, services die when processing data.
➔ Unless that data is persisted, it’s lost forever.
➔ Queues mitigate this by persisting data until it has been
fully processed.
➔ No job gets lost.
10 benefits of
using message
queues
Decoupling
Redundancy
Load Balancing,
Scalability
Elasticity &
Spikability
Resiliency
Delivery Guarantees
Ordering
Guarantees
Buffering
Data Flow
visibility
Asynchronous
communication
10 benefits of
using message
queues
Decoupling
Redundancy
Load Balancing,
Scalability
Elasticity &
Spikability
Resiliency
Delivery Guarantees
Ordering
Guarantees
Buffering
Data Flow
visibility
Asynchronous
communication
Load Balancing, Scalability
➔ It’s easy to scale up the rate with which messages are added to the
queue or processed – by adding more instances.
➔ Easy to create load balancing by attaching multiple workers to a single
queue.
➔ No code changes, no configurations need to be tweaked.
➔ Scaling is as simple as adding more power.
10 benefits of
using message
queues
Decoupling
Redundancy
Load Balancing,
Scalability
Elasticity &
Spikability
Resiliency
Delivery Guarantees
Ordering
Guarantees
Buffering
Data Flow
visibility
Asynchronous
communication
10 benefits of
using message
queues
Decoupling
Redundancy
Load Balancing,
Scalability
Elasticity &
Spikability
Resiliency
Delivery Guarantees
Ordering
Guarantees
Buffering
Data Flow
visibility
Asynchronous
communication
Elasticity & Spikability
➔ When your application hits the front page of Hacker News, you’re going to see
unusual levels of traffic.
➔ Your application needs to be able to keep functioning.
➔ But the traffic is anomaly, not the standard — it’s wasteful to have enough
resources on standby to handle these spikes.
➔ Message queues will allow components to struggle through the increased
load, instead of getting overloaded with requests and failing completely.
➔ Queue lengths and consumer utilization = basis for auto-scaling.
10 benefits of
using message
queues
Decoupling
Redundancy
Load Balancing,
Scalability
Elasticity &
Spikability
Resiliency
Delivery Guarantees
Ordering
Guarantees
Buffering
Data Flow
visibility
Asynchronous
communication
10 benefits of
using message
queues
Decoupling
Redundancy
Load Balancing,
Scalability
Elasticity &
Spikability
Resiliency
Delivery Guarantees
Ordering
Guarantees
Buffering
Data Flow
visibility
Asynchronous
communication
Resiliency
➔ When part of your architecture fails, it doesn’t need to take the entire system
down :-)
➔ Message queues decouple services, so if a service that is processing
messages from the queue fails, messages can still be added to the queue to
be processed when the system recovers.
➔ This ability to accept requests that will be retried or processed at a later date is
often the difference between an inconvenienced customer and a frustrated
customer.
10 benefits of
using message
queues
Decoupling
Redundancy
Load Balancing,
Scalability
Elasticity &
Spikability
Resiliency
Delivery Guarantees
Ordering
Guarantees
Buffering
Data Flow
visibility
Asynchronous
communication
10 benefits of
using message
queues
Decoupling
Redundancy
Load Balancing,
Scalability
Elasticity &
Spikability
Resiliency
Delivery Guarantees
Ordering
Guarantees
Buffering
Data Flow
visibility
Asynchronous
communication
Delivery guarantees
➔ The redundancy provided by message queues guarantees that a
message will eventually be processed.
➔ No matter how many processes are pulling data from the queue, each
message will be processed at least once.
➔ This is often made possible using a way to “reserve” messages being
processed, temporarily removing them from the queue.
➔ Unless the client specifically states that it’s finished with that message,
the message will be placed back to the top of the queue.
10 benefits of
using message
queues
Decoupling
Redundancy
Load Balancing,
Scalability
Elasticity &
Spikability
Resiliency
Delivery Guarantees
Ordering
Guarantees
Buffering
Data Flow
visibility
Asynchronous
communication
10 benefits of
using message
queues
Decoupling
Redundancy
Load Balancing,
Scalability
Elasticity &
Spikability
Resiliency
Delivery Guarantees
Ordering
Guarantees
Buffering
Data Flow
visibility
Asynchronous
communication
Ordering Guarantees
➔ In a lot of situations, the order with which data is processed is
important.
➔ Message queues are inherently ordered, and capable of providing
guarantees that data will be processed in a specific order.
➔ Most message queues use FIFO (first in, first out), so the order in which
messages are placed on a queue is the order in which they’ll be
retrieved from it.
➔ (Beware when using multiple consumers)
10 benefits of
using message
queues
Decoupling
Redundancy
Load Balancing,
Scalability
Elasticity &
Spikability
Resiliency
Delivery Guarantees
Ordering
Guarantees
Buffering
Data Flow
visibility
Asynchronous
communication
10 benefits of
using message
queues
Decoupling
Redundancy
Load Balancing,
Scalability
Elasticity &
Spikability
Resiliency
Delivery Guarantees
Ordering
Guarantees
Buffering
Data Flow
visibility
Asynchronous
communication
Buffering
➔ In any non-trivial system, there are going to be components that
require different processing times.
➔ For example, it takes less time to upload an image than it does to apply
a filter to it.
➔ You can also collect a certain number of items together and process
them as a single batch.
10 benefits of
using message
queues
Decoupling
Redundancy
Load Balancing,
Scalability
Elasticity &
Spikability
Resiliency
Delivery Guarantees
Ordering
Guarantees
Buffering
Data Flow
visibility
Asynchronous
communication
10 benefits of
using message
queues
Decoupling
Redundancy
Load Balancing,
Scalability
Elasticity &
Spikability
Resiliency
Delivery Guarantees
Ordering
Guarantees
Buffering
Data Flow
visibility
Asynchronous
communication
Data Flow Visibility
➔ In a distributed system, getting an overall sense of where and how data flows
can be a daunting task.
➔ Message queues, and routing rules, help identify and understand data flow
paths.
➔ Through the rate with which they are processed, one can easily identify under-
performing processes or areas where the data flow is not optimal.
Queues queues queues — How RabbitMQ enables reactive architectures
10 benefits of
using message
queues
Decoupling
Redundancy
Load Balancing,
Scalability
Elasticity &
Spikability
Resiliency
Delivery Guarantees
Ordering
Guarantees
Buffering
Data Flow
visibility
Asynchronous
communication
10 benefits of
using message
queues
Decoupling
Redundancy
Load Balancing,
Scalability
Elasticity &
Spikability
Resiliency
Delivery Guarantees
Ordering
Guarantees
Buffering
Data Flow
visibility
Asynchronous
communication
Async Communication
➔ A lot of times, you don’t want to or need to process a message
immediately.
➔ Message queues enable asynchronous processing, which allows you
to put a message on the queue without processing it immediately.
➔ Queue up as many messages as you like, then process them at your
leisure.
➔ Opens possibilities for retry-later setups.
10 benefits of
using message
queues
Decoupling
Redundancy
Load Balancing,
Scalability
Elasticity &
Spikability
Resiliency
Delivery Guarantees
Ordering
Guarantees
Buffering
Data Flow
visibility
Asynchronous
communication
10 benefits of
using message
queues
Decoupling
Redundancy
Load Balancing,
Scalability
Elasticity &
Spikability
Resiliency
Delivery Guarantees
Ordering
Guarantees
Buffering
Data Flow
visibility
Asynchronous
communication
http://www.iron.io/top-10-uses-for-message-queue/
RabbitMQ
RabbitMQ
➔ An AMQP messaging broker
➔ Written in Erlang
➔ Launched in 2007
➔ Originally written by Rabbit Technologies Ltd. in London, UK
➔ Got acquired in 2010 by a division of VMWare
➔ Spin-off in 2013 to Pivotal Software, Inc
➔ Core participant of the AMQP working group
AMQP
➔ Advanced Message Queue Protocol
➔ An open standard, independent from RabbitMQ
➔ Provider agnostic, in theory.
A client should be able to swap RabbitMQ with different AMQP server
➔ Client libraries available for all major programming languages
➔ Most recent specification version is 1.0. *
* RabbitMQ mostly AMQP version 0.9.1 as of Feb 2016.
Queues queues queues — How RabbitMQ enables reactive architectures
RabbitMQ server
Basic concept
binding
Publisher
RabbitMQ server
Basic concept
Publisher Exchange
RabbitMQ server
Basic concept
Publisher
Queue
Queue
Exchange
RabbitMQ server
Basic concept
Publisher
Queue
Queue
binding
binding
Exchange
RabbitMQ server
Basic concept
Publisher
Consumer
Queue
Queue
binding
binding
Exchange
RabbitMQ server
Basic concept
Consumer
Consumer
Consumer
Publisher
Queue
Queue
binding
binding
Exchange
RabbitMQ server
Basic concept
statistics
queue
webhook
queue
#
#.company_15
deals
exchange
Deals
service
statistics
service
webhook
service
webhook
service
Queue
Queue
binding
binding
Exchange
Consumer
Consumer
Consumer
RabbitMQ server
Basic concept
Publisher
Publishing
Publishing
➔ Your apps publish messages. Each message has
◆ routing key (e.g. subject)
◆ delivery mode (persistent or not persistent)
◆ headers (e.g. { "content-type": "application/json" })
◆ payload (e.g. { "some": "json" })
◆ properties (e.g. correlation-id)
Queues queues queues — How RabbitMQ enables reactive architectures
Queue
Queue
binding
binding
Exchange
RabbitMQ server
Consumer
Consumer
Consumer
Basic concept
Publisher
Publishing
RabbitMQ server
Exchange
Basic concept
Consumer
Consumer
Consumer
Publisher
Queue
Queue
binding
binding
Exchange
Exchanges
➔ Exchanges are AMQP entities where
messages are sent to.
➔ Exchanges on their own are useless,
unless bound to something.
https://www.rabbitmq.com/tutorials/amqp-concepts.html
Four types of exchanges
➔ Direct, Fanout, Topic, Headers
➔ Type defines how you can bind from it
➔ Most useful is Topic (allows regexp-like bindings)
➔ Read more from RabbitMQ docs
Queue
Queue
binding
binding
Exchange
RabbitMQ server
Exchange
Basic concept
Consumer
Consumer
Consumer
Publisher
Queue
Queue
binding
binding
Exchange
RabbitMQ server
Basic concept
Bindings
Consumer
Consumer
Consumer
Publisher
Bindings
➔ Rules with which messages are routed
from exchanges to queues
➔ Each queue and exchange can have multiple
bindings
➔ Examples: [characteristic].[color].[kind]
◆ *.orange.*
◆ *.*.rabbit
◆ lazy.#
Bindings
Q1 is interested in all the orange animals.
Q2 wants to hear everything about rabbits, and everything about lazy animals.
Queue
Queue
binding
binding
Exchange
RabbitMQ server
Basic concept
Bindings
Consumer
Consumer
Consumer
Publisher
Queue
Queue
binding
binding
Exchange
RabbitMQ server
Basic concept
Consumer
Consumer
Consumer
Publisher
Queues
Queues
➔ Ordered lists of messages to be consumed
➔ FIFO
➔ Can be either durable or transient
➔ Can have arguments (behavioral properties)
TTL of messages in it
auto-expiry
maximum length
dead letter handling
Queue
Queue
binding
binding
Exchange
RabbitMQ server
Basic concept
Consumer
Consumer
Consumer
Publisher
Queues
RabbitMQ server
Basic concept
Queue
Queue
binding
binding
Exchange
Consuming
Consumer
Consumer
Consumer
Publisher
Consuming
➔ Act of receiving and acting upon messages from a
queue
Consuming
➔ Act of receiving and acting upon messages from a
queue
➔ One at a time, or multiple-in-flight with acking
Consuming
➔ Act of receiving and acting upon messages from a
queue
➔ One at a time, or multiple-in-flight with acking
➔ Delivery and execution guarantees
Consuming
➔ Act of receiving and acting upon messages from a
queue
➔ One at a time, or multiple-in-flight with acking
➔ Delivery and execution guarantees
➔ One queue can have multiple consumers (enables load
balancing — but then exact order is not guaranteed)
Consuming
➔ Act of receiving and acting upon messages from a
queue
➔ One at a time, or multiple-in-flight with acking
➔ Delivery and execution guarantees
➔ One queue can have multiple consumers (enables load
balancing — but then exact order is not guaranteed)
➔ A consumer may ask for exclusivity
Consumption sequence diagram
RabbitMQ Consumer
RabbitMQ Consumer
[message]
Consumption sequence diagram
RabbitMQ Consumer
RabbitMQ Consumer
[message]
mark
message
‘unacked’
Consumption sequence diagram
RabbitMQ Consumer
RabbitMQ Consumer
[message]
mark
message
‘unacked’ attempt to process
the message
Consumption sequence diagram
RabbitMQ Consumer
RabbitMQ Consumer
[message]
mark
message
‘unacked’ attempt to process
the messageack
Consumption sequence diagram
RabbitMQ Consumer
RabbitMQ Consumer
[message]
mark
message
‘unacked’ attempt to process
the messageack
mark
message
delivered
Consumption sequence diagram with a failure
RabbitMQ Consumer
RabbitMQ Consumer
[message]
Consumption sequence diagram with a failure
RabbitMQ Consumer
RabbitMQ Consumer
[message]
mark
message
‘unacked’
Consumption sequence diagram with a failure
RabbitMQ Consumer
RabbitMQ Consumer
[message]
mark
message
‘unacked’
attempt to process
the message
Consumption sequence diagram with a failure
RabbitMQ Consumer
RabbitMQ Consumer
[message]
mark
message
‘unacked’
attempt to process
the message
dies!
Consumption sequence diagram with a failure
RabbitMQ Consumer
RabbitMQ Consumer
[message]
mark
message
‘unacked’
attempt to process
the message
(connection reset) dies!
Consumption sequence diagram with a failure
RabbitMQ Consumer
RabbitMQ Consumer
[message]
mark
message
‘unacked’
attempt to process
the message
(connection reset) dies!
put message
back to
‘ready’
Consumption sequence diagram with a failure
RabbitMQ Consumer
RabbitMQ Consumer
[message]
mark
message
‘unacked’
attempt to process
the message
(connection reset) dies!
put message
back to
‘ready’
Consumer
Consumer
Consumption sequence diagram with a failure
RabbitMQ Consumer
RabbitMQ Consumer
[message]
mark
message
‘unacked’
attempt to process
the message
(connection reset) dies!
put message
back to
‘ready’
Consumer
Consumer
[message]
mark message ‘unacked’
Consumer characteristics (Node.js)
➔ Persistent TCP connection to AMQP server
➔ RabbitMQ pushes messages to consumer (no polling)
➔ Connection is multiplexed (using channels)
➔ Event listener/callback function is executed per each
message, with ack() callback provided to be called
when a message can be considered consumed.
RabbitMQ server
Basic concept
Publisher
Queue
Queue
binding
binding
Consumer
Consumer
Consumer
Exchange
RabbitMQ server
Basic concept
Deals
service
statistics
queue
webhook
queue
#
#.company_15
statistics
service
webhook
service
deals
exchange
webhook
service
RabbitMQ server
Basic concept
Deals
service
deals
exchange
Photos
service
statistics
queue
webhook
queue
statistics
service
webhook
service
webhook
service
photos
exchange
RabbitMQ server
Basic concept
Deals
service
statistics
queue
webhook
queue
statistics
service
webhook
service
deals
exchange
webhook
service
Photos
service
photos
exchange
analyzer
queue
analyzer
service
RabbitMQ server
Basic concept
Deals
service
statistics
queue
webhook
queue
statistics
service
webhook
service
deals
exchange
webhook
service
Photos
service
photos
exchange
analyzer
queue
analyzer
service
resizing
queue photo resizer
service
So it’s like…
a series of tubes.
Queues queues queues — How RabbitMQ enables reactive architectures
Some like to call it
“a post box, a post office
and a postman, all in one”...
“When you send mail to the post
box you're pretty sure that Mr.
Postman will eventually deliver
the mail to your recipient. Using
this metaphor RabbitMQ is a
post box, a post office and a
postman.”
From the RabbitMQ official tutorial.
However,
in a microservices environment,
this post metaphor can be
dangerous.
The post metaphor can lure you into
publishing messages with a specific
consumer in mind,
thus increasing tight coupling which
makes it harder to add other kinds of
consumers in the future without having
to change multiple services.
Example:
Orchestration vs
choreography
User signs up
Example use case shown by Sam Newman in “Principles of microservices” presentation
User signs up
Create user account
Example use case shown by Sam Newman in “Principles of microservices” presentation
User signs up
Create user account
Sign up to newsletter
at MailChimp
Example use case shown by Sam Newman in “Principles of microservices” presentation
User signs up
Create user account
Sign up to newsletter
at MailChimp
Send welcome email
Example use case shown by Sam Newman in “Principles of microservices” presentation
User signs up
Create user account
Sign up to newsletter
at MailChimp
Send welcome email Send welcome gift
Example use case shown by Sam Newman in “Principles of microservices” presentation
User signs up
Create user account
Sign up to newsletter
at MailChimp
Send welcome email Send welcome gift
Example use case shown by Sam Newman in “Principles of microservices” presentation
Done!
Orchestration
Example use case shown by Sam Newman in “Principles of microservices” presentation
Sign up
service
Orchestration
Example use case shown by Sam Newman in “Principles of microservices” presentation
Orchestration
Sign up
service
Newsletter
service
subscribe
Example use case shown by Sam Newman in “Principles of microservices” presentation
Orchestration
Sign up
service
Newsletter
service
Email
sendersubscribe
send email
Example use case shown by Sam Newman in “Principles of microservices” presentation
Orchestration
Sign up
service
Newsletter
service
Email
sender
Delivery
service
subscribe
send email
send package
➔ With orchestration, messages (commands, really) sent from service A
to others end up being explicit and with a single recipient in mind.
Problem with orchestration — tight coupling
➔ With orchestration, messages (commands, really) sent from service A
to others end up being explicit and with a single recipient in mind.
➔ Makes it hard to plug in new services along the way, and thus shape
the system organically.
Problem with orchestration — tight coupling
➔ With orchestration, messages (commands, really) sent from service A
to others end up being explicit and with a single recipient in mind.
➔ Makes it hard to plug in new services along the way, and thus shape
the system organically.
➔ Expectations of replies to completed commands — seeing a “send this
newsletter out” command in service A may seem like it is a
synchronous action, whereas with a message queue it is not.
Problem with orchestration — tight coupling
Choreography
https://www.flickr.com/photos/stevenpisano/16313427202
Choreography
Sign up
service
Example use case shown by Sam Newman in “Principles of microservices” presentation
Example use case shown by Sam Newman in “Principles of microservices” presentation
Choreography
Sign up
service
user signed up
Example use case shown by Sam Newman in “Principles of microservices” presentation
Choreography
Sign up
service
Newsletter
service
user signed up
Example use case shown by Sam Newman in “Principles of microservices” presentation
Choreography
Sign up
service
Email
sender
Newsletter
service
user signed up
Example use case shown by Sam Newman in “Principles of microservices” presentation
Choreography
Sign up
service
Email
sender
Delivery
service
Newsletter
service
user signed up
Choreography
Sign up
service
Newsletter
service
Email
sender
Delivery
service
RabbitMQ
Queue
Queue
signups
Queue
Example use case shown by Sam Newman in “Principles of microservices” presentation
➔ Responsive
User does not have to wait for all services to complete their work, thus gets
the response faster.
Choreography
➔ Responsive
User does not have to wait for all services to complete their work, thus gets
the response faster.
➔ Resilient
Failure is tolerated in each service separately — if one fails then the work is
queued and processing will eventually still happen, after error is removed.
Choreography
➔ Responsive
User does not have to wait for all services to complete their work, thus gets
the response faster.
➔ Resilient
Failure is tolerated in each service separately — if one fails then the work is
queued and processing will eventually still happen, after error is removed.
➔ Elastic
Queue lengths can be used to scale consuming services up or down.
Choreography
➔ Responsive
User does not have to wait for all services to complete their work, thus gets
the response faster.
➔ Resilient
Failure is tolerated in each service separately — if one fails then the work is
queued and processing will eventually still happen, after error is removed.
➔ Elastic
Queue lengths can be used to scale consuming services up or down.
➔ Works well with message queues. Allows reactive architectures.
Choreography
So, embrace
choreography
wherever possible.
Dumb pipes,
smart endpoints
Dumb
service A
Dumb
service B
Dumb
service C
Dumb
service D
Dumb
service A
Dumb
service B
Dumb
service C
Dumb
service D
Enterprise Service Bus
Dumb
service A
Dumb
service B
Dumb
service C
Dumb
service D
Dumb
service A
Dumb
service B
Dumb
service C
Dumb
service D
Magic Mystery Bus
Example credit to Sam Newman in “Principles of microservices” presentation.
Dumb
service A
Dumb
service B
Dumb
service C
Dumb
service D
Dumb
service A
Dumb
service B
Dumb
service C
Dumb
service D
Magic Mystery Bus
Dumb pipes, smart endpoints
➔ Initially, you deploy an empty RabbitMQ.
Dumb pipes, smart endpoints
➔ Initially, you deploy an empty RabbitMQ.
➔ Do not make RabbitMQ deployment be aware
of the desired data flows.
Dumb pipes, smart endpoints
➔ Initially, you deploy an empty RabbitMQ.
➔ Do not make RabbitMQ deployment be aware
of the desired data flows.
➔ Exchanges, bindings and queues are created
by services themselves as they need.
RabbitMQ server
Basic concept
Deals
service
statistics
queue
webhook
queue
#
#.company_15
statistics
service
webhook
service
deals
exchange
webhook
service
RabbitMQ server
Basic concept political map
Deals
service
statistics
queue
webhook
queue
#
#.company_15
statistics
service
webhook
service
deals
exchange
webhook
service
RabbitMQ server
Basic concept political map
Deals
service
statistics
queue
webhook
queue
#
#.company_15
statistics
service
webhook
service
deals
exchange
webhook
serviceKingdom of
Deals Service
Commonwealth of
Statistics Service
Republic of
Webhook Service
So, in essence,
RabbitMQ is left with
nothing but the
dumb pipes.
Smart
service A
Smart
service B
Smart
service C
Smart
service D
Smart
service A
Smart
service B
Smart
service C
Smart
service D
Dumb pipes
RabbitMQ
in the wild
RabbitMQ at Pipedrive
➔ Started using in 2012
RabbitMQ at Pipedrive
➔ Started using in 2012
➔ Main backbone of async service-to-service communication
RabbitMQ at Pipedrive
➔ Started using in 2012
➔ Main backbone of async service-to-service communication
➔ All data change events are published to RabbitMQ.
RabbitMQ at Pipedrive
➔ Started using in 2012
➔ Main backbone of async service-to-service communication
➔ All data change events are published to RabbitMQ.
➔ Averaging around >1,700 msg/sec. Peaking sometimes at
3,000+ msg/sec. >140M msg/day.
RabbitMQ at Pipedrive
➔ Started using in 2012
➔ Main backbone of async service-to-service communication
➔ All data change events are published to RabbitMQ.
➔ Averaging around >1,700 msg/sec. Peaking sometimes at
3,000+ msg/sec. >140M msg/day.
RabbitMQ at Pipedrive
RabbitMQ at Pipedrive
➔ Initially deployed a 3-node cluster
MQ
MQ
MQ
RabbitMQ at Pipedrive
➔ Initially deployed a 3-node cluster
➔ Then scaled it up to a 5-node cluster
MQ
MQ
MQ
MQ
MQ
MQ
MQ
MQ
RabbitMQ at Pipedrive
➔ Initially deployed a 3-node cluster
➔ Then scaled it up to a 5-node cluster
➔ Then decided to move to multiple 3-node clusters instead
MQ
MQ
MQ
MQ
MQ
MQ
MQ
MQ
MQ
MQ
MQ
MQ
MQ
MQ
RabbitMQ at Pipedrive
RabbitMQ at Pipedrive
➔ Started seeing networking overhead in a 5-node cluster as
the load grew.
RabbitMQ at Pipedrive
➔ Started seeing networking overhead in a 5-node cluster as
the load grew.
➔ Multiple clusters with semi-isolated traffic (bound by either
SLA or logical service groups) was easier to handle for us.
RabbitMQ at Pipedrive
➔ Started seeing networking overhead in a 5-node cluster as
the load grew.
➔ Multiple clusters with semi-isolated traffic (bound by either
SLA or logical service groups) was easier to handle for us.
➔ It was a logical architecture decision, not a technical
constraint — RabbitMQ does scale well beyond our load.
3 caveats
1.
Who owns an
exchange?
Exchange ownership question
Exchange ownership question
➔ Ultimately, every service will depend on existence of certain exchanges.
Exchange ownership question
➔ Ultimately, every service will depend on existence of certain exchanges.
➔ If these are missing, binding will throw an error.
Exchange ownership question
➔ Ultimately, every service will depend on existence of certain exchanges.
➔ If these are missing, binding will throw an error.
➔ But which service should create the exchange?
There should ideally be only one owner per each exchange.
Exchange ownership question
➔ Ultimately, every service will depend on existence of certain exchanges.
➔ If these are missing, binding will throw an error.
➔ But which service should create the exchange?
There should ideally be only one owner per each exchange.
➔ At Pipedrive, we have so far had shared exchange ownerships. Eventually it
could create problems down the line as exchange properties are defined in
multiple services.
Exchange ownership question
➔ Ultimately, every service will depend on existence of certain exchanges.
➔ If these are missing, binding will throw an error.
➔ But which service should create the exchange?
There should ideally be only one owner per each exchange.
➔ At Pipedrive, we have so far had shared exchange ownerships. Eventually it
could create problems down the line as exchange properties are defined in
multiple services.
➔ Possible solution: die consumers when an exchange does not exist?
2.
Adding/removing bindings
is like changing a database
schema
Adding/removing bindings is like changing schema
Adding/removing bindings is like changing schema
➔ With high throughput, adding and removing bindings from
a busy exchange can be like changing your DB schema.
Adding/removing bindings is like changing schema
➔ With high throughput, adding and removing bindings from
a busy exchange can be like changing your DB schema.
➔ It takes time.
Adding/removing bindings is like changing schema
➔ With high throughput, adding and removing bindings from
a busy exchange can be like changing your DB schema.
➔ It takes time.
➔ At Pipedrive, we used to create a queue+binding for each
logged in user to facilitate websocket connection back to
end user’s browser.
Adding/removing bindings is like changing schema
➔ With high throughput, adding and removing bindings from
a busy exchange can be like changing your DB schema.
➔ It takes time.
➔ At Pipedrive, we used to create a queue+binding for each
logged in user to facilitate websocket connection back to
end user’s browser.
➔ Don’t do it.
tl;dr:
RabbitMQ is optimized for
throughput of messages,
not for throughput of
schema changes on the fly.
At Pipedrive, we have a
microservice we call
socketqueue.
It’s a piping service between
user’s browser and RabbitMQ
websocket User’s browser
socketqueue
(consumer)
RabbitMQ
REST APIs
(publishers)
AMQPAMQP
Socketqueue 1.0 architecture
➔ One queue + binding per each connected user
➔ One Websocket connection per each connected user
➔ One-to-one relation between queue and websocket
inside the socketqueue service.
➔ Horizontally scalable
RabbitMQ cluster
Socketqueue 1.0 architecture
REST APIs
q3
api.events
exchange
q2
q1
socketq1
u1
u2
u3
q6
q5
q4
socketq2
u4
u5
u6
q8 socketq3
u7
u8
u9
q7
+ 10K more
q9
300+ msg/sec
RabbitMQ cluster
Socketqueue 1.0 architecture
REST APIs
q3
api.events
exchange
q2
q1
socketq1
u1
u2
u3
q6
q5
q4
socketq2
u4
u5
u6
q8 socketq3
u7
u8
u9
q7
+ 10K more
q9
Did not scale
beyond 10K
queues,
bindings
300+ msg/sec
RabbitMQ cluster
Socketqueue 1.0 architecture
REST APIs
q3
api.events
exchange
q2
q1
socketq1
u1
u2
u3
q6
q5
q4
socketq2
u4
u5
u6
q8 socketq3
u7
u8
u9
q7
+ 10K more
q9
300+ msg/sec
Socketqueue 2.0 architecture
REST APIs
api.events
exchange
q-socket1 socketq1
u1
u2
u3
q-socket2 socketq2
u4
u5
u6
socketq3
u7
u8
u9
q-socket3
RabbitMQ cluster
300+ msg/sec
Socketqueue 1.0 architecture
➔ One queue + binding per each connected user
➔ One Websocket connection per each connected user
➔ One-to-one relation between queue and websocket
inside the socketqueue service.
➔ Horizontally scalable
Socketqueue 1.02.0 architecture
➔ One queue + binding per each connected user
socketqueue service instance.
➔ One Websocket connection per each connected user
➔ One-to-onemany relation between queue and websocket
inside the socketqueue service.
➔ Horizontally scalable well beyond 10K simultaneous users
Most problematic?
Initial setup of 10K+ queues/bindings
during version upgrades, service restarts.
3.
Delivery guarantees
100% delivery guarantee
=
Publisher Acknowledgements
Publisher Acknowledgements
➔ Your service sends a persistent message to RabbitMQ
Publisher Acknowledgements
➔ Your service sends a persistent message to RabbitMQ
➔ RabbitMQ receives your message but does not yet write it to disk
Publisher Acknowledgements
➔ Your service sends a persistent message to RabbitMQ
➔ RabbitMQ receives your message but does not yet write it to disk
➔ RabbitMQ tells you it has received your message
Publisher Acknowledgements
➔ Your service sends a persistent message to RabbitMQ
➔ RabbitMQ receives your message but does not yet write it to disk
➔ RabbitMQ tells you it has received your message
➔ The message gets routed to a durable queue
Publisher Acknowledgements
➔ Your service sends a persistent message to RabbitMQ
➔ RabbitMQ receives your message but does not yet write it to disk
➔ RabbitMQ tells you it has received your message
➔ The message gets routed to a durable queue
➔ A consumer picks up the message and starts processing it
Publisher Acknowledgements
➔ Your service sends a persistent message to RabbitMQ
➔ RabbitMQ receives your message but does not yet write it to disk
➔ RabbitMQ tells you it has received your message
➔ The message gets routed to a durable queue
➔ A consumer picks up the message and starts processing it
➔ RabbitMQ server dies and comes back up
Publisher Acknowledgements
➔ Your service sends a persistent message to RabbitMQ
➔ RabbitMQ receives your message but does not yet write it to disk
➔ RabbitMQ tells you it has received your message
➔ The message gets routed to a durable queue
➔ A consumer picks up the message and starts processing it
➔ RabbitMQ server dies and comes back up
➔ Except, that message that was being processed? It’s not there any more.
100% delivery guarantee
=
Publisher Acknowledgements
Read more from https://www.rabbitmq.com/confirms.html
RabbitMQ elsewhere
https://blog.pivotal.io/pivotal/products/rabbitmq-hits-one-million-messages-per-second-on-google-compute-engine
1 million
messages per second
1,000,000
messages per second
86,400,000,000
messages per day
Queues queues queues — How RabbitMQ enables reactive architectures
To put this into
context...
11B
2014 all of SMS traffic
per day globally
http://techcrunch.com/2015/04/22/facebook-voip-not-facebook-phone/
http://www.openuniversity.edu/news/news/2014-text-messaging-usage-statistics
http://www.businessinsider.com/eddy-cue-200k-imessages-per-second-2016-2
17.2B
11B
2014 all of SMS traffic
per day globally
2016 Apple iMessages
per day globally
http://techcrunch.com/2015/04/22/facebook-voip-not-facebook-phone/
http://www.openuniversity.edu/news/news/2014-text-messaging-usage-statistics
http://www.businessinsider.com/eddy-cue-200k-imessages-per-second-2016-2
17.2B
11B
2014 all of SMS traffic
per day globally
2016 Apple iMessages
per day globally
Facebook, Messenger,
and WhatsApp per day
combined
45B
http://techcrunch.com/2015/04/22/facebook-voip-not-facebook-phone/
http://www.openuniversity.edu/news/news/2014-text-messaging-usage-statistics
http://www.businessinsider.com/eddy-cue-200k-imessages-per-second-2016-2
86.4B
17.2B
11B
2014 all of SMS traffic
per day globally
2016 Apple iMessages
per day globally
That single RabbitMQ
experiment
Facebook, Messenger,
and WhatsApp per day
combined
45B
http://techcrunch.com/2015/04/22/facebook-voip-not-facebook-phone/
http://www.openuniversity.edu/news/news/2014-text-messaging-usage-statistics
http://www.businessinsider.com/eddy-cue-200k-imessages-per-second-2016-2
I think that’s pretty
remarkable.
Queues queues queues — How RabbitMQ enables reactive architectures
Thank you.
Martin Tajur
@tajur on Twitter
With this promo code
DEVCLUBEE
2 months free
www.pipedrive.com
Thank you.
Martin Tajur
@tajur on Twitter
With this promo code
DEVCLUBEE
2 months free
www.pipedrive.com
We’re
hiring.
Questions/Answers

More Related Content

PPTX
RabbitMq
PPTX
Rabbit MQ introduction
PPTX
Spring RabbitMQ
PDF
Dissecting the rabbit: RabbitMQ Internal Architecture
PDF
Messaging with amqp and rabbitmq
PDF
Rabbitmq basics
PDF
RabbitMQ fairly-indepth
PDF
Distributed messaging with AMQP
RabbitMq
Rabbit MQ introduction
Spring RabbitMQ
Dissecting the rabbit: RabbitMQ Internal Architecture
Messaging with amqp and rabbitmq
Rabbitmq basics
RabbitMQ fairly-indepth
Distributed messaging with AMQP

What's hot (19)

PPT
Easy enterprise application integration with RabbitMQ and AMQP
PDF
RabbitMQ Data Ingestion
PPTX
Rabbitmq & Kafka Presentation
PDF
Do More With Message Queue
PDF
AMQP for phpMelb
PDF
Rabbitmq, amqp Intro - Messaging Patterns
ODP
The Art of Message Queues - TEKX
PDF
Messaging Standards and Systems - AMQP & RabbitMQ
PPTX
Making communications across boundaries simple with NServiceBus
PPT
Succeding with the Apache SOA stack
PPT
Apache ActiveMQ - Enterprise messaging in action
PPTX
Making communication across boundaries simple with Azure Service Bus
ODP
Art Of Message Queues
PPT
An Introduction to Apache ServiceMix 4 - FUSE ESB
PPT
Implementing WebServices with Camel and CXF in ServiceMix
PDF
Enterprise Messaging with Apache ActiveMQ
PPTX
Introduction to NServiceBus
PPT
AMQP and RabbitMQ (OKCJUG, January 2014)
ODP
Apache ActiveMQ and Apache Camel
Easy enterprise application integration with RabbitMQ and AMQP
RabbitMQ Data Ingestion
Rabbitmq & Kafka Presentation
Do More With Message Queue
AMQP for phpMelb
Rabbitmq, amqp Intro - Messaging Patterns
The Art of Message Queues - TEKX
Messaging Standards and Systems - AMQP & RabbitMQ
Making communications across boundaries simple with NServiceBus
Succeding with the Apache SOA stack
Apache ActiveMQ - Enterprise messaging in action
Making communication across boundaries simple with Azure Service Bus
Art Of Message Queues
An Introduction to Apache ServiceMix 4 - FUSE ESB
Implementing WebServices with Camel and CXF in ServiceMix
Enterprise Messaging with Apache ActiveMQ
Introduction to NServiceBus
AMQP and RabbitMQ (OKCJUG, January 2014)
Apache ActiveMQ and Apache Camel
Ad

Similar to Queues queues queues — How RabbitMQ enables reactive architectures (20)

PDF
The Why and How of Applications with APIs and microservices
PPTX
PeopleSoft and The Cloud
PPTX
Service Mesh CTO Forum (Draft 3)
DOC
Ranadip Basak
PDF
The Business Value of PaaS Automation - Kieron Sambrook-Smith - Presentation ...
PPTX
Service Meshes Made Easy
PDF
Consul: Service-oriented at Scale
PDF
#JaxLondon keynote: Developing applications with a microservice architecture
PDF
Developing Applications with a Micro Service Architecture - Chris Richardson
PDF
From Monoliths to Microservices at Realestate.com.au
PDF
How to Build a Scalable Web Application for Your Project
PPTX
Concepto de “new normal”: Arquitectura híbrida
PDF
Service Mesh Talk for CTO Forum
PPTX
What are microservices
PDF
Manage the Digital Transformation with Machine Learning in a Reactive Microse...
PPTX
Tef con2016 (1)
PDF
Amazon web services quick guide - tutorialspoint
PPT
At 306 Case Study The Newest Shipping Systems Its All About Rapid Informa...
PDF
Eventos y Microservicios - Santander TechTalk
PDF
Best of re:Invent 2016 meetup presentation
The Why and How of Applications with APIs and microservices
PeopleSoft and The Cloud
Service Mesh CTO Forum (Draft 3)
Ranadip Basak
The Business Value of PaaS Automation - Kieron Sambrook-Smith - Presentation ...
Service Meshes Made Easy
Consul: Service-oriented at Scale
#JaxLondon keynote: Developing applications with a microservice architecture
Developing Applications with a Micro Service Architecture - Chris Richardson
From Monoliths to Microservices at Realestate.com.au
How to Build a Scalable Web Application for Your Project
Concepto de “new normal”: Arquitectura híbrida
Service Mesh Talk for CTO Forum
What are microservices
Manage the Digital Transformation with Machine Learning in a Reactive Microse...
Tef con2016 (1)
Amazon web services quick guide - tutorialspoint
At 306 Case Study The Newest Shipping Systems Its All About Rapid Informa...
Eventos y Microservicios - Santander TechTalk
Best of re:Invent 2016 meetup presentation
Ad

Recently uploaded (20)

PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
Nekopoi APK 2025 free lastest update
PDF
Understanding Forklifts - TECH EHS Solution
PPTX
ai tools demonstartion for schools and inter college
PDF
System and Network Administration Chapter 2
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Nekopoi APK 2025 free lastest update
Understanding Forklifts - TECH EHS Solution
ai tools demonstartion for schools and inter college
System and Network Administration Chapter 2
wealthsignaloriginal-com-DS-text-... (1).pdf
Odoo POS Development Services by CandidRoot Solutions
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Wondershare Filmora 15 Crack With Activation Key [2025
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Design an Analysis of Algorithms I-SECS-1021-03
VVF-Customer-Presentation2025-Ver1.9.pptx
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Softaken Excel to vCard Converter Software.pdf
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Reimagine Home Health with the Power of Agentic AI​
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf

Queues queues queues — How RabbitMQ enables reactive architectures