SlideShare a Scribd company logo
@asgrim
this slide is intentionally left blank
@asgrim
Before we begin...
Copy folder from USB to your local machine.
$ cd /path/to/the/folder/you/copied/from/usb/
$ vagrant box add asgrim/rmq-vm rmq-vm.box
$ vagrant up --no-provision
Test it in your browser...
http://192.168.33.99:15672/
@asgrim
Introducing
Practical RabbitMQ
James Titcumb
James Titcumb
www.jamestitcumb.com
www.roave.com
www.phphants.co.uk
www.phpsouthcoast.co.uk
@asgrim
Who is this guy?
@asgrim Photo: http://spitalfieldslife.com/2011/08/27/a-fox-in-hoxton-2/
@asgrim
What is a message?
@asgrim
What is message queueing?
@asgrim
Separation of Concerns
@asgrim
Scaling with Rabbit
RabbitMQApplication
Background processing
@asgrim
Scaling with Rabbit
RabbitMQApplication
Background processing
Background processing
@asgrim
Scaling with Rabbit
RabbitMQApplication
Background processing
Background processing
Background processing
@asgrim
Scaling with Rabbit
RabbitMQApplication
Background processing
Background processing
Background processing
Background processing
@asgrim
Scaling with Rabbit
RabbitMQApplication
Background processing
Background processing
Background processing
Background processing
Background processing
@asgrim
AMQP
@asgrim
AMQP Low Level Frame
1 1 67 <frame payload> 0xCE
@asgrim
AMQP Frame: Basic.Publish
<frame payload>
Publish <exchange> <routing key> <flag>
1 1 67 0xCE
Basic
@asgrim
AMQP Message: Multiple Frames
1 1 67 Basic.Publish 0xCE
2 1 102 Content Header 0xCE
3 1 1024 Body 0xCE
3 1 1024 Body 0xCE
3 1 1024 Body 0xCE
3 1 1024 Body 0xCE
@asgrim
AMQP Headers
● content-type
@asgrim
AMQP Headers
● content-type
● content-encoding
@asgrim
AMQP Headers
● content-type
● content-encoding
● message-id
@asgrim
AMQP Headers
● content-type
● content-encoding
● message-id
● correlation-id
● reply-to
@asgrim
AMQP Headers
● content-type
● content-encoding
● message-id
● correlation-id
● reply-to
● expiration
@asgrim
AMQP Headers
● content-type
● content-encoding
● message-id
● correlation-id
● reply-to
● expiration
● priority
@asgrim
AMQP Headers
● content-type
● content-encoding
● message-id
● correlation-id
● reply-to
● expiration
● priority
● headers
@asgrim
Real world uses?
@asgrim
Who is using it?
@asgrim
SOA
@asgrim
Why RabbitMQ?
@asgrim
(you need Vagrant+VirtualBox already)
Installing RabbitMQ
@asgrim
vagrant up
Copy folder from USB to your local machine.
$ cd /path/to/the/folder/you/copied/from/usb/
$ vagrant box add asgrim/rmq-vm rmq-vm.box
$ vagrant up --no-provision
Test it in your browser...
http://192.168.33.99:15672/
@asgrim
Library with Composer
composer require php-amqplib/php-amqplib
@asgrim
The Management Console
http://192.168.33.99:15672/
@asgrim
Practical
@asgrim
https://github.com/asgrim/rmq-tutorial
@asgrim
Objective: Basic Queuing
Producer Consumer
test_queue
1 2 3 4 5
@asgrim
Get vs Consume
@asgrim
Exchanges: Fanout
@asgrim
Objective: Fanout Exchange
test_exchange
amq.KfgPZ3PE
amq.cK5Cp3FC
Consumer
Consumer
Producer
1
1
2
2
3
3
4
4
5
5
@asgrim
A word on Temporary Queues
test_exchangeProducer
Messages
go nowhere
@asgrim
Exchanges: Direct
@asgrim
Objective: Direct Exchange
test_direct
BK = apple
BK = banana, apple
Consumer
Consumer
Producer
BK = orange, banana,
apple
Consumer
@asgrim
Objective: Direct Exchange
test_direct
BK = apple
BK = banana, apple
Consumer
Consumer
Producer
MESSAGE
ROUTING KEY
= ORANGE
BK = orange, banana,
apple
Consumer
@asgrim
Objective: Direct Exchange
test_direct
BK = apple
BK = banana, apple
Consumer
Consumer
Producer
MESSAGE
ROUTING KEY
= BANANA
BK = orange, banana,
apple
Consumer
@asgrim
Objective: Direct Exchange
test_direct
BK = apple
BK = banana, apple
Consumer
Consumer
Producer
MESSAGE
ROUTING KEY
= APPLE
BK = orange, banana,
apple
Consumer
@asgrim
Exchanges: Topic
@asgrim
Objective:
Topic Exchange
test_topic
BK = *.vegetable
BK = #
Consumer
Consumer
Producer
BK = green.#
Consumer
BK = *.grass.* / *.*.long
Consumer
@asgrim
Objective:
Topic Exchange
test_topic
BK = *.vegetable
BK = #
Consumer
Consumer
Producer
RED.VEGETABLE
BK = green.#
Consumer
BK = *.grass.* / *.*.long
Consumer
@asgrim
Objective:
Topic Exchange
test_topic
BK = *.vegetable
BK = #
Consumer
Consumer
Producer
GREEN.VEGETABLE
BK = green.#
Consumer
BK = *.grass.* / *.*.long
Consumer
@asgrim
Objective:
Topic Exchange
test_topic
BK = *.vegetable
BK = #
Consumer
Consumer
Producer
GREEN.GRASS.LONG
BK = green.#
Consumer
BK = *.grass.* / *.*.long
Consumer
@asgrim
Message Acknowledgement
@asgrim
Another Example
@asgrim
@asgrim
Fetch message
Logging Sequence
ApplicationBrowser Log Server
HTTP request
JSON via AMQP
Error!
HTTP response
RabbitMQ
@asgrim
Flexibility!
@asgrim
Parallel Processing
@asgrim
test_exchange
amq.KfgPZ3PE
amq.cK5Cp3FC
Consumer
Producer
1
1
2
2
3
3
4
4
5
5
Consumer
Consumer
Consumer
Consumer
Consumer
Consumer
Consumer
Parallel Processing
@asgrim
RPC
@asgrim
RPC example
Producer Consumer
test_queue
1
reply_to: amq.gen-Xa2
1’
@asgrim
TTL
@asgrim
TTL - per queue message
Producer Consumer
test_queue
1 2 3 4 5
}
10s
@asgrim
TTL - per message
Producer Consumer
test_queue
1 2 3 4 5
5s 3s 7s 1s 9s
@asgrim
TTL - queue
Producer
test_queue
}
5s (if no consumers)
@asgrim Photo: © Rob Allen (akrabat) https://flic.kr/p/6wp9iz
@asgrim
DLX
@asgrim
DLX
test_exchange
amq.KfgPZ3PE
Producer 1
dlx_exchange
dlx_queue
1
@asgrim
Scheduling / Delayed messages
@asgrim
Shovel
@asgrim
Federated Queues
@asgrim
Federated Queues
1 Consumer
WAN
Rabbit Node #1 Rabbit Node #2
my_queue my_queue (federated)
@asgrim
Priority
@asgrim
Management HTTP API
@asgrim
Infrastructure
@asgrim
Problem: SPOF
@asgrim
Solution 1: Clustering
@asgrim
Clustering
RabbitMQ
Node 1
RabbitMQ
Node 3
RabbitMQ
Node 2
RabbitMQ
Node 4
RabbitMQ
Node 5
RabbitMQ
Node 6
Load Balance / Floating IP / Low TTL DNS etc.
@asgrim
Everything Replicates
(except queues…)
@asgrim
Disk / RAM
@asgrim
Configuration...
@asgrim
/etc/rabbitmq/rabbitmq.config
[
{rabbit, [
{loopback_users, []},
{vm_memory_high_watermark, 0.8}
]}
].
@asgrim
/etc/rabbitmq/rabbitmq.config
[{{{[{{[{{}}{][[[{[{{}[[}{[[{}[][}{}}}{}}{{,},]{
[[{rabbit, [{{}[[}{,,{}[][}{[][][{}{{{{}}}}[[}{{
{{}}{loopback_users, []},[][][]{}{}{}<}{[}[][][}
[{{[{vm_memory_high_watermark, 0.8}]]{}{[[[]]{}]
{{]}[{[{{}[[}{]]{}[][,{}[][}{[][][{}.[]}{]][][]}
]...{}[][,]{.}[][}{}[[[{}{][]}{}{}[}{}{}{]{}{}}[
@asgrim
node1$ rabbitmqctl cluster_status
Cluster status of node rabbit@node1 ...
[{nodes,[{disc,[rabbit@node1]}]},{running_nodes,[rabbit@node1]}]
...done.
Creating a cluster
@asgrim
node2$ rabbitmqctl join_cluster --ram rabbit@node1
node3$ rabbitmqctl join_cluster rabbit@node2
node3$ rabbitmqctl cluster_status
Cluster status of node rabbit@node3 ...
[{nodes,[{disc,[rabbit@node3,rabbit@node1]},{ram,[rabbit@node2]}]},
{running_nodes,[rabbit@node2,rabbit@node1,rabbit@node3]}]
...done.
Creating a cluster
@asgrim
Starting/Stopping Nodes
@asgrim
node1$ rabbitmqctl stop_app
node2$ rabbitmqctl forget_cluster_node rabbit@node1
node1$ rabbitmqctl reset
node1$ rabbitmqctl start_app
node2$ rabbitmqctl cluster_status
Cluster status of node rabbit@node2 ...
[{nodes,[{disc,[rabbit@node3]},{ram,[rabbit@node2]}]},
{running_nodes,[rabbit@node2,rabbit@node3]}]
...done.
Removing Nodes
@asgrim
Solution 2: HA
@asgrim
HA + Queue Mirroring
RabbitMQ
Node 1
RabbitMQ
Node 2
Load Balance / Floating IP / Low TTL DNS etc.
@asgrim
BunnyPHP
@asgrim
composer require bunny/bunny
@asgrim
Challenge!
Any questions?
https://joind.in/talk/be4e5
James Titcumb @asgrim

More Related Content

Viewers also liked (20)

PDF
Presentation Bulgaria PHP
Alena Holligan
 
PDF
Git Empowered
Jason McCreary
 
PDF
Dip Your Toes in the Sea of Security
James Titcumb
 
PPTX
Php extensions
Elizabeth Smith
 
PDF
SunshinePHP 2017 - Making the most out of MySQL
Gabriela Ferrara
 
PDF
Conscious Coupling
CiaranMcNulty
 
PDF
200K+ reasons security is a must
Michelangelo van Dam
 
PDF
Intermediate OOP in PHP
David Stockton
 
PPTX
Modern sql
Elizabeth Smith
 
PDF
PHP World DC 2015 - What Can Go Wrong with Agile Development and How to Fix It
Matt Toigo
 
PDF
Enough suffering, fix your architecture!
Luís Cobucci
 
PDF
Website Accessibility: It’s the Right Thing to do
DesignHammer
 
PPTX
Automating Your Workflow with Gulp.js - php[world] 2016
Colin O'Dell
 
PDF
Getting instantly up and running with Docker and Symfony
André Rømcke
 
PDF
Kicking off with Zend Expressive and Doctrine ORM (Sunshine PHP 2017)
James Titcumb
 
PDF
How I started to love design patterns
Samuel ROZE
 
PPTX
Debugging Effectively - SunshinePHP 2017
Colin O'Dell
 
PPTX
A World Without PHP
Ben Marks
 
PDF
Redis for your boss
Elena Kolevska
 
PDF
Decouple your framework now, thank me later
Michelangelo van Dam
 
Presentation Bulgaria PHP
Alena Holligan
 
Git Empowered
Jason McCreary
 
Dip Your Toes in the Sea of Security
James Titcumb
 
Php extensions
Elizabeth Smith
 
SunshinePHP 2017 - Making the most out of MySQL
Gabriela Ferrara
 
Conscious Coupling
CiaranMcNulty
 
200K+ reasons security is a must
Michelangelo van Dam
 
Intermediate OOP in PHP
David Stockton
 
Modern sql
Elizabeth Smith
 
PHP World DC 2015 - What Can Go Wrong with Agile Development and How to Fix It
Matt Toigo
 
Enough suffering, fix your architecture!
Luís Cobucci
 
Website Accessibility: It’s the Right Thing to do
DesignHammer
 
Automating Your Workflow with Gulp.js - php[world] 2016
Colin O'Dell
 
Getting instantly up and running with Docker and Symfony
André Rømcke
 
Kicking off with Zend Expressive and Doctrine ORM (Sunshine PHP 2017)
James Titcumb
 
How I started to love design patterns
Samuel ROZE
 
Debugging Effectively - SunshinePHP 2017
Colin O'Dell
 
A World Without PHP
Ben Marks
 
Redis for your boss
Elena Kolevska
 
Decouple your framework now, thank me later
Michelangelo van Dam
 

Similar to Adding 1.21 Gigawatts to Applications with RabbitMQ (Bulgaria PHP 2016 - Tutorial) (20)

PDF
Introducing Practical RabbitMQ (php[tek] 2016 - Tutorial)
James Titcumb
 
PDF
Get Started with RabbitMQ (CoderCruise 2017)
James Titcumb
 
PDF
Adding 1.21 Gigawatts to Applications with RabbitMQ (PHP Oxford June Meetup 2...
James Titcumb
 
PDF
Adding 1.21 Gigawatts to Applications with RabbitMQ (DPC 2015)
James Titcumb
 
PDF
Adding 1.21 Gigawatts to Applications with RabbitMQ (PHPNW Dec 2014 Meetup)
James Titcumb
 
PDF
Adding 1.21 Gigawatts to Applications with RabbitMQ (PHP UK 2015)
James Titcumb
 
PDF
Messaging with amqp and rabbitmq
Selasie Hanson
 
PDF
Practical Message Queueing using RabbitMQ (Nomad PHP EU Dec 2014)
James Titcumb
 
KEY
Message queueing
Richard Jones
 
KEY
Message Queueing - by an MQ noob
Richard Jones
 
PDF
Messaging Standards and Systems - AMQP & RabbitMQ
POSSCON
 
PDF
What RabbitMQ can do for you (phpnw14 Uncon)
James Titcumb
 
PDF
Построение распределенной системы сбора данных с помощью RabbitMQ, Alvaro Vid...
Ontico
 
PDF
Messaging Standards and Systems - AMQP & RabbitMQ
All Things Open
 
PDF
Follow the White Rabbit - Message Queues with PHP
Eric Rodriguez (Hiring in Lex)
 
PDF
Reducing load with RabbitMQ
Povilas Balzaravičius
 
PDF
Practical Message Queuing Using RabbitMQ (PHPem, 3rd July 2014)
James Titcumb
 
PDF
RabbitMQ fairly-indepth
Wee Keat Chin
 
PPTX
Rabbit MQ
Tran Thanh Thi
 
PPTX
Scaling application with RabbitMQ
Nahidul Kibria
 
Introducing Practical RabbitMQ (php[tek] 2016 - Tutorial)
James Titcumb
 
Get Started with RabbitMQ (CoderCruise 2017)
James Titcumb
 
Adding 1.21 Gigawatts to Applications with RabbitMQ (PHP Oxford June Meetup 2...
James Titcumb
 
Adding 1.21 Gigawatts to Applications with RabbitMQ (DPC 2015)
James Titcumb
 
Adding 1.21 Gigawatts to Applications with RabbitMQ (PHPNW Dec 2014 Meetup)
James Titcumb
 
Adding 1.21 Gigawatts to Applications with RabbitMQ (PHP UK 2015)
James Titcumb
 
Messaging with amqp and rabbitmq
Selasie Hanson
 
Practical Message Queueing using RabbitMQ (Nomad PHP EU Dec 2014)
James Titcumb
 
Message queueing
Richard Jones
 
Message Queueing - by an MQ noob
Richard Jones
 
Messaging Standards and Systems - AMQP & RabbitMQ
POSSCON
 
What RabbitMQ can do for you (phpnw14 Uncon)
James Titcumb
 
Построение распределенной системы сбора данных с помощью RabbitMQ, Alvaro Vid...
Ontico
 
Messaging Standards and Systems - AMQP & RabbitMQ
All Things Open
 
Follow the White Rabbit - Message Queues with PHP
Eric Rodriguez (Hiring in Lex)
 
Reducing load with RabbitMQ
Povilas Balzaravičius
 
Practical Message Queuing Using RabbitMQ (PHPem, 3rd July 2014)
James Titcumb
 
RabbitMQ fairly-indepth
Wee Keat Chin
 
Rabbit MQ
Tran Thanh Thi
 
Scaling application with RabbitMQ
Nahidul Kibria
 
Ad

More from James Titcumb (20)

PDF
Living the Best Life on a Legacy Project (phpday 2022).pdf
James Titcumb
 
PDF
Tips for Tackling a Legacy Codebase (ScotlandPHP 2021)
James Titcumb
 
PDF
Climbing the Abstract Syntax Tree (Midwest PHP 2020)
James Titcumb
 
PDF
Best practices for crafting high quality PHP apps (Bulgaria 2019)
James Titcumb
 
PDF
Climbing the Abstract Syntax Tree (php[world] 2019)
James Titcumb
 
PDF
Best practices for crafting high quality PHP apps (php[world] 2019)
James Titcumb
 
PDF
Crafting Quality PHP Applications (PHP Joburg Oct 2019)
James Titcumb
 
PDF
Climbing the Abstract Syntax Tree (PHP Russia 2019)
James Titcumb
 
PDF
Best practices for crafting high quality PHP apps - PHP UK 2019
James Titcumb
 
PDF
Climbing the Abstract Syntax Tree (ScotlandPHP 2018)
James Titcumb
 
PDF
Best practices for crafting high quality PHP apps (ScotlandPHP 2018)
James Titcumb
 
PDF
Kicking off with Zend Expressive and Doctrine ORM (PHP South Africa 2018)
James Titcumb
 
PDF
Best practices for crafting high quality PHP apps (PHP South Africa 2018)
James Titcumb
 
PDF
Climbing the Abstract Syntax Tree (PHP Developer Days Dresden 2018)
James Titcumb
 
PDF
Climbing the Abstract Syntax Tree (Southeast PHP 2018)
James Titcumb
 
PDF
Crafting Quality PHP Applications (PHPkonf 2018)
James Titcumb
 
PDF
Best practices for crafting high quality PHP apps (PHP Yorkshire 2018)
James Titcumb
 
PDF
Crafting Quality PHP Applications: an overview (PHPSW March 2018)
James Titcumb
 
PDF
Kicking off with Zend Expressive and Doctrine ORM (PHP MiNDS March 2018)
James Titcumb
 
PDF
Climbing the Abstract Syntax Tree (PHP UK 2018)
James Titcumb
 
Living the Best Life on a Legacy Project (phpday 2022).pdf
James Titcumb
 
Tips for Tackling a Legacy Codebase (ScotlandPHP 2021)
James Titcumb
 
Climbing the Abstract Syntax Tree (Midwest PHP 2020)
James Titcumb
 
Best practices for crafting high quality PHP apps (Bulgaria 2019)
James Titcumb
 
Climbing the Abstract Syntax Tree (php[world] 2019)
James Titcumb
 
Best practices for crafting high quality PHP apps (php[world] 2019)
James Titcumb
 
Crafting Quality PHP Applications (PHP Joburg Oct 2019)
James Titcumb
 
Climbing the Abstract Syntax Tree (PHP Russia 2019)
James Titcumb
 
Best practices for crafting high quality PHP apps - PHP UK 2019
James Titcumb
 
Climbing the Abstract Syntax Tree (ScotlandPHP 2018)
James Titcumb
 
Best practices for crafting high quality PHP apps (ScotlandPHP 2018)
James Titcumb
 
Kicking off with Zend Expressive and Doctrine ORM (PHP South Africa 2018)
James Titcumb
 
Best practices for crafting high quality PHP apps (PHP South Africa 2018)
James Titcumb
 
Climbing the Abstract Syntax Tree (PHP Developer Days Dresden 2018)
James Titcumb
 
Climbing the Abstract Syntax Tree (Southeast PHP 2018)
James Titcumb
 
Crafting Quality PHP Applications (PHPkonf 2018)
James Titcumb
 
Best practices for crafting high quality PHP apps (PHP Yorkshire 2018)
James Titcumb
 
Crafting Quality PHP Applications: an overview (PHPSW March 2018)
James Titcumb
 
Kicking off with Zend Expressive and Doctrine ORM (PHP MiNDS March 2018)
James Titcumb
 
Climbing the Abstract Syntax Tree (PHP UK 2018)
James Titcumb
 
Ad

Recently uploaded (20)

PPTX
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PPTX
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PDF
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 

Adding 1.21 Gigawatts to Applications with RabbitMQ (Bulgaria PHP 2016 - Tutorial)