SlideShare una empresa de Scribd logo
1 de 40
Descargar para leer sin conexión
AYANDA DUBE
ERLANG SOLUTIONS LTD
RABBITMQ
DESIGN & ARCHITECTURE
12/11/2018
Twitter: dube_aya Github: Ayanda-D Email: ayandaonline@gmail.com
QUICK ADDITIONAL ACKNOWLEDGEMENTS
▸ Saskia Kuipers (ESL)
▸ Johan Rhodin and Lovisa Johansson (84codes)
▸ Pieter Humphrey (Pivotal)
▸ Pivotal Engineering Team for all the great work, as always! (Dan Carwin’s team)
▸ Everyone here, Erlang Solutions customers, some who’ve traveled from quite far
GOAL: DESIGN & ARCHITECTURE
P C
▸ Explain the internal design and architecture of rabbit
APP-1 APP-2
▸ Ever present need for efficient communication
QUOTE
"A picture is worth a thousand words"
- Fred Barnard
- Ayanda Dube …. (last night!)
"A software system diagram is worth a thousand lines of code”
INITIALIZATION: START SCRIPTS
INITIALIZATION: START SCRIPTS
rabbitmq-server
rabbitmq-env
rabbitmq-defaults
erl
RABBITMQ_NODENAME
RABBITMQ_NODENAME
CONFIG_FILE
LOG_BASE
MNESIA_BASE
ENABLED_PLUGINS_FILE
INITIALIZATION: ERLANG NODE
RABBITMQ_START_RABBIT
INITIALIZATION: RABBIT BOOT MODULE
RABBITMQ_BOOT_MODULE = rabbit
rabbit:boot( )
INITIALIZATION: BOOT
rabbit boot!
update application configs
hipe compile
initialise logging
log hipe compile result
prepare cluster status files
upgrade mnesia
check cluster consistency
Broker Start!
rabbitmq.config
INITIALIZATION: BROKER START
setup plugins
start applications + plugins
sd notify (“READY”)
log broker started
run boot steps
INITIALIZATION: BOOT STEPS
codec_correctness_check
rabbit_alarm
database (rabbit_mnesia)
database_sync (mnesia_sync)
file_handle_cache
worker_pool
rabbit_registry
rabbit_core_metrics
rabbit_memory_monitor
guid_generator (rabbit_gui)
delegate_sup (mnesia_sync)
rabbit_node_monitor
rabbit_epmd_monitor
upgrade_queues
recovery
empty_db_check
direct_client
connection_tracking
networking
notify_cluster
background_gc
rabbit_core_metrics_gc
rabbit_looking_glass
internal boot steps
kernel_ready
external_infrastructure
core_initialized
routing_ready
rabbit_event log_relay
pre_boot
plugin boot steps
INITIALIZATION: INTERNAL BOOT STEPS
auth mechanisms
exchange types
queue mirror modes
policies (e.g. validators)
queue master locators
vhost limits
priority queue
runtime parameters
enabled
INITIALIZATION: NODE STATE
mnesia5672
PLUGINS
rabbit
alarm
rabbit
reader
rabbit
memory
monitor
rabbit
node
monitor
recovery
file
handle
cache
rabbit
registry
rabbit
Sup
worker
pool
rabbit
epmd
monitor
delegate
sup
D=16
rabbit_user
rabbit_user_permission
rabbit_vhost
rabbit_queue
rabbit_durable_queue
rabbit_route
AMQP
P C
▸ Connection establishment
mnesia
5672
PLUGINS
rabbit
alarm
rabbit
reader
rabbit
memory
monitor
rabbit
node
monitor
recovery
file
handle
cache
rabbit
registry
rabbit
Sup
worker
pool
rabbit
epmd
monitor
delegate
sup
D=16
INITIALIZED
APP-1 APP-2
AMQP HANDLING: CONNECTION ESTABLISHMENT
rabbit
channel_0
5671P rabbit
reader
RANCH
TCP connect
5672 rabbit
writer
rabbit
connection
sup
ranch
acceptor
proc_lib
#TCP Sock#
connection.start
connection.start_ok [login]
connection.tune
connection.tune_ok
[login success]
connection.open
connection.open_ok
assemble
frame
assemble
frame
assemble
frame
TCP
AMQP
#AMQP-Connection#
AMQP HANDLING: CONNECTION ESTABLISHMENT
rabbit reader
main_loop
receive messge(Socket)
handle input
handshake
<<"AMQP", A, B, C, D, Rest/binary>>
Aquire Framing Module
{A, B, C, D}
{0, 0, 9, 1}
{1, 1, 0, 9}
{1, 1, 8, 0}
rabbit_framing_amqp_0_8
rabbit_framing_amqp_0_9_1
rabbit_framing_amqp_0_9_1
{1, 1, 8, 0}
rabbit_framing_amqp_0_8
{ID, 1, 0, 0}
rabbit_amqp1_0_reader
start_connection
AMQP 1.0 infrastructure
register connection PID
(pg_group)
set server properties
set auth mechanisms
connection.start{ }
send on channel 0
rabbit writer
send command
AMQP HANDLING: CONNECTION ESTABLISHMENT
rabbit
sup
tcp_listener
suptcp_listener
ranch
listener
sup
ranch
conns
sup
ranch
acceptors
sup
rabbit
connection
sup
Protocol
rabbit
connection
sup
rabbit
reader
rabbit
connection
helper
10
ranch
acceptor
ProtocolPid
rabbit reader
recvloop(Socket)
{active, once}
mainloop recv
handle_input FSM
Transport:accept/2
CLIENT
CONNECTION
REQUESTS
RANCH
Started on BOOT
AMQP HANDLING: NODE STATE
P C
▸ Connection establishment
▸ Channel creation
ch1
ch2
Ch3
ch1
ch2
ch3
AMQP HANDLING: CHANNEL OPEN
rabbit
channel sup
5672 rabbit
channel
P rabbit
reader
channel.open
rabbit
channel
common
rabbit
channel sup
sup
channel.open
ChPid
channel.open
rabbit
writer
channel.open_ok
AMQP HANDLING: CHANNEL OPEN
rabbit reader
receive
loop(Socket)
{active, once}
handle input FSM
Channel 0?
Y
handle method 0
process frame
handle AMQP
frame
N
lookup
Channel
ChPID
rabbit_command
assembler
create new channel
undefined
ChannelMax?
N
rabbit_channel_sup_sup
start_channel
store ChPID (dictionary)
{ch_pid, ChPid}
{channel, Channel}
Y
ChannelCount + 1
Protocol
decode_method_fields
e.g. Protocol = rabbit_framing_amqp_0_9_1
rabbit_channel:do
Method
handle_cast( Method )
gen_server:cast/2
Method
Update Channel State
“running”
Channel Created Stats
ChPID
AMQP HANDLING: CHANNEL OPEN
rabbit
channel
sup sup
rabbit
channel
sup
rabbit
limiter
rabbit
writer
rabbit
channel
DIRECT
NETWORK
AMQP: NODE STATE
P C
▸ Connection establishment
▸ Channel creation
▸ Create/declare an exchange
ch2
AMQP HANDLING: EXCHANGE DECLARATION
5672 rabbit
channel
P rabbit
reader
exchange.declare
rabbit
exchange
exchange.declare_ok
rabbit
exchange
type
exchange.declare_ok
direct
fanout
topic
headers
custom
insert
lookup
{ok, X}
not_found
declare
AMQP HANDLING: EXCHANGE DECLARATION
rabbit channel
exchange.declare
valid type?
Y
N
configure
permitted?
N
Y
lookup
X
{ok, X} {error, not_found}
RETURN DECLARE
MNESIAexchange.declare_ok
exchange.declare_ok
AMQP: NODE STATE
▸ Connection establishment
P C
▸ Channel creation
▸ Create/declare an exchange
ch2
▸ Create/declare a queue
AMQP HANDLING: QUEUE DECLARATION
5672 rabbit
channel
P
queue.declare
rabbit
amqqueue
queue.declare_ok
rabbit
queue
process
queue.declare_ok
lookup
{ok, Q}
not_found
queue stats [M, C]
delegate
stat
backing
queue
queue.declare_ok nowait
declare
rabbit
queue
process sup
init
{new, Q}
{ok, Q, 0, 0}
BQ:len
BQ:init
[Q, Durable, AutoDelete, Args, …]
AMQP HANDLING: QUEUE DECLARATION
rabbit_amqque:declare
queue.bind
set policy
queue master location
mirroring queue master
location node
rabbit queue supervisor
Node
rabbit prequeue process
Queue
StartMode
Slave
Start Queue Master Start Queue Slave
Master
Q
Initialize Queue Index
Initiaze Message
Store(s)
Q ! {init, new}
BQ:init
initialization
Transient
Persistent
AMQP: NODE STATE
▸ Connection establishment
▸ Channel creation
▸ Create/declare an exchange
▸ Create/declare a queue
▸ Bind queue to exchange
P Cch2
AMQP HANDLING: QUEUE TO EXCHANGE BINDING
5672 rabbit
channel
P
queue.bind [Q, X]
rabbit
binding
queue.bind_ok
read
[ _ ]
[ ]
add
add(Q, X)
rabbit_route
rabbit_route
rabbit_durable_route
rabbit_semi_durable_route
queue.bind_ok
AMQP HANDLING: QUEUE TO EXCHANGE BINDING
rabbit channel
queue.bind
format SRC & DST
strip “n” and “r”
resource names
Y
write
permitted DST?
Y
N
Is default X?
N
Y
read
permitted X?
Y
N
RETURN
rabbit_binding
valid
binding?
N
lookup
binding
[ _ ]
Y
[]
INSERT BINDING
MNESIA
queue.bind_ok
rabbit writer
AMQP: NODE STATE
▸ Connection establishment
▸ Channel creation
▸ Declare an exchange
▸ Declare a queue
▸ Bind queue to exchange
▸ Subscribe Consumer
P Cch2
AMQP HANDLING: CONSUMING
rabbit
channelP
basic.consume
rabbit
queue
process
basic_consume
delegaterabbit
amqqueue
rabbit
queue
consumers
ChPid
LimiterPid
basic_consume
add
ChPid
rabbit
limiter
LimiterPid activate
priority
queue
in [ChPid, Consumer]
core
metrics
consumer_created
basic.consume_ok
OPERATIONS: NODE STATE
▸ Connection establishment
P C
▸ Channel creation
▸ Declare an exchange
ch2
▸ Declare a queue
▸ Bind queue to exchange
▸ Subscribe consumer
▸ Publish messages
ch2
ch2
ch2
AMQP HANDLING: MESSAGE PUBLISH
rabbit
channelP
basic.publish
rabbit
queue
process
message
route
Queue(s)
rabbit
basic
backing
queue
delivery
rabbit
exchange delegate
#delivery [M, Queues]
rabbit
amqqueue
#delivery{}
rabbit
queue
consumer
delivery_attempt
is_duplicate?
publish
QPids
AMQP HANDLING: BACKING QUEUE
rabbit
queue
process
backing
queue
rabbit
queue index
embed?
publish
rabbit
queue msg
store
msg_store
#msg_status{ }
Transient
Persistent
or
Internal BQ
Queues
store[ #msg_status ]
Q1 [ALPHAs]
Q2 [BETAS & GAMMAS]
Q3 [BETAS & GAMMAS]
Q4 [ALPHAs]
ALPHA
BETA
GAMMA
DELTA
RAM
MSG POS
RAM
DISK RAM
DISK RAM & DISK
DISK DISK
#delivery{}
AMQP: NODE STATE
P Cch2 ch2
ch2
ch2
APP-1 APP-2
OPERATIONS: CLUSTERING
▸ Adding “extra nodes” to mnesia configuration
▸ Replication and synchronisation of metadata
▸ Internal internode routing/referencing
synch synch
▸ Default distribution port 25672
OPERATIONS: HA QUEUES
M S1 S2
gm gm gmC
synch synch
▸ Backing queue switches to the mirror queue master
GM
▸ HA policies dynamically update queue state
▸ Synchronisation over Erlang distribution
CONCLUSION: DESIGN & ARCHITECTURE
▸ Not entirely fixed/static, common aspects
▸ Usage varies its internal design
▸ Creation and tearing down of resources (AMQP)
▸ Plugins will alter operation and design
▸ Version releases introduce design and architecture shifts
https://github.com/rabbitmq/rabbitmq-server/
https://github.com/rabbitmq/rabbitmq-common/
END: THANK YOU!
QUESTIONS
Twitter: dube_aya Github: Ayanda-D Email: ayandaonline@gmail.com

Más contenido relacionado

La actualidad más candente

Awx user guide
Awx user guideAwx user guide
Awx user guide
mspirko
 

La actualidad más candente (20)

Network architecture design for microservices on GCP
Network architecture design for microservices on GCPNetwork architecture design for microservices on GCP
Network architecture design for microservices on GCP
 
Proxmox for DevOps
Proxmox for DevOpsProxmox for DevOps
Proxmox for DevOps
 
Introduction to kubernetes
Introduction to kubernetesIntroduction to kubernetes
Introduction to kubernetes
 
Gatekeeper: API gateway
Gatekeeper: API gatewayGatekeeper: API gateway
Gatekeeper: API gateway
 
Red Hat multi-cluster management & what's new in OpenShift
Red Hat multi-cluster management & what's new in OpenShiftRed Hat multi-cluster management & what's new in OpenShift
Red Hat multi-cluster management & what's new in OpenShift
 
Introduction to GraphQL using Nautobot and Arista cEOS
Introduction to GraphQL using Nautobot and Arista cEOSIntroduction to GraphQL using Nautobot and Arista cEOS
Introduction to GraphQL using Nautobot and Arista cEOS
 
Kubernetes Networking - Sreenivas Makam - Google - CC18
Kubernetes Networking - Sreenivas Makam - Google - CC18Kubernetes Networking - Sreenivas Makam - Google - CC18
Kubernetes Networking - Sreenivas Makam - Google - CC18
 
Cilium - Bringing the BPF Revolution to Kubernetes Networking and Security
Cilium - Bringing the BPF Revolution to Kubernetes Networking and SecurityCilium - Bringing the BPF Revolution to Kubernetes Networking and Security
Cilium - Bringing the BPF Revolution to Kubernetes Networking and Security
 
What's Coming in CloudStack 4.19
What's Coming in CloudStack 4.19What's Coming in CloudStack 4.19
What's Coming in CloudStack 4.19
 
Awx user guide
Awx user guideAwx user guide
Awx user guide
 
Enabling NFV features in kubernetes
Enabling NFV features in kubernetesEnabling NFV features in kubernetes
Enabling NFV features in kubernetes
 
可靠分布式系统基础 Paxos的直观解释
可靠分布式系统基础 Paxos的直观解释可靠分布式系统基础 Paxos的直观解释
可靠分布式系统基础 Paxos的直观解释
 
Cluster-as-code. The Many Ways towards Kubernetes
Cluster-as-code. The Many Ways towards KubernetesCluster-as-code. The Many Ways towards Kubernetes
Cluster-as-code. The Many Ways towards Kubernetes
 
Disaster Recovery Options Running Apache Kafka in Kubernetes with Rema Subra...
 Disaster Recovery Options Running Apache Kafka in Kubernetes with Rema Subra... Disaster Recovery Options Running Apache Kafka in Kubernetes with Rema Subra...
Disaster Recovery Options Running Apache Kafka in Kubernetes with Rema Subra...
 
Using eBPF for High-Performance Networking in Cilium
Using eBPF for High-Performance Networking in CiliumUsing eBPF for High-Performance Networking in Cilium
Using eBPF for High-Performance Networking in Cilium
 
Shift Deployment Security Left with Weave GitOps & Upbound’s Universal Crossp...
Shift Deployment Security Left with Weave GitOps & Upbound’s Universal Crossp...Shift Deployment Security Left with Weave GitOps & Upbound’s Universal Crossp...
Shift Deployment Security Left with Weave GitOps & Upbound’s Universal Crossp...
 
The Role of IAM in Microservices
The Role of IAM in MicroservicesThe Role of IAM in Microservices
The Role of IAM in Microservices
 
Operator Framework Overview
Operator Framework OverviewOperator Framework Overview
Operator Framework Overview
 
Demystify eBPF JIT Compiler
Demystify eBPF JIT CompilerDemystify eBPF JIT Compiler
Demystify eBPF JIT Compiler
 
cilium-public.pdf
cilium-public.pdfcilium-public.pdf
cilium-public.pdf
 

Similar a A walk-through of the design and architecture of RabbitMQ - Ayanda Dube

H2O World - What's New in H2O with Cliff Click
H2O World - What's New in H2O with Cliff ClickH2O World - What's New in H2O with Cliff Click
H2O World - What's New in H2O with Cliff Click
Sri Ambati
 
Intravert Server side processing for Cassandra
Intravert Server side processing for CassandraIntravert Server side processing for Cassandra
Intravert Server side processing for Cassandra
Edward Capriolo
 

Similar a A walk-through of the design and architecture of RabbitMQ - Ayanda Dube (20)

Scylla Summit 2017: SMF: The Fastest RPC in the West
Scylla Summit 2017: SMF: The Fastest RPC in the WestScylla Summit 2017: SMF: The Fastest RPC in the West
Scylla Summit 2017: SMF: The Fastest RPC in the West
 
Incrementalism: An Industrial Strategy For Adopting Modern Automation
Incrementalism: An Industrial Strategy For Adopting Modern AutomationIncrementalism: An Industrial Strategy For Adopting Modern Automation
Incrementalism: An Industrial Strategy For Adopting Modern Automation
 
Streaming Way to Webscale: How We Scale Bitly via Streaming
Streaming Way to Webscale: How We Scale Bitly via StreamingStreaming Way to Webscale: How We Scale Bitly via Streaming
Streaming Way to Webscale: How We Scale Bitly via Streaming
 
Evolution of kube-proxy (Brussels, Fosdem 2020)
Evolution of kube-proxy (Brussels, Fosdem 2020)Evolution of kube-proxy (Brussels, Fosdem 2020)
Evolution of kube-proxy (Brussels, Fosdem 2020)
 
Pycon - Python for ethical hackers
Pycon - Python for ethical hackers Pycon - Python for ethical hackers
Pycon - Python for ethical hackers
 
Containerizing Distributed Pipes
Containerizing Distributed PipesContainerizing Distributed Pipes
Containerizing Distributed Pipes
 
H2O World - What's New in H2O with Cliff Click
H2O World - What's New in H2O with Cliff ClickH2O World - What's New in H2O with Cliff Click
H2O World - What's New in H2O with Cliff Click
 
DockerCon EU '17 - Dockerizing Aurea
DockerCon EU '17 - Dockerizing AureaDockerCon EU '17 - Dockerizing Aurea
DockerCon EU '17 - Dockerizing Aurea
 
N flavors of streaming
N flavors of streamingN flavors of streaming
N flavors of streaming
 
XDP in Practice: DDoS Mitigation @Cloudflare
XDP in Practice: DDoS Mitigation @CloudflareXDP in Practice: DDoS Mitigation @Cloudflare
XDP in Practice: DDoS Mitigation @Cloudflare
 
Kubernetes Navigation Stories – DevOpsStage 2019, Kyiv
Kubernetes Navigation Stories – DevOpsStage 2019, KyivKubernetes Navigation Stories – DevOpsStage 2019, Kyiv
Kubernetes Navigation Stories – DevOpsStage 2019, Kyiv
 
Advanced Shell Scripting for Oracle professionals
Advanced Shell Scripting for Oracle professionalsAdvanced Shell Scripting for Oracle professionals
Advanced Shell Scripting for Oracle professionals
 
Intravert Server side processing for Cassandra
Intravert Server side processing for CassandraIntravert Server side processing for Cassandra
Intravert Server side processing for Cassandra
 
NYC* 2013 - "Advanced Data Processing: Beyond Queries and Slices"
NYC* 2013 - "Advanced Data Processing: Beyond Queries and Slices"NYC* 2013 - "Advanced Data Processing: Beyond Queries and Slices"
NYC* 2013 - "Advanced Data Processing: Beyond Queries and Slices"
 
ql.io at NodePDX
ql.io at NodePDXql.io at NodePDX
ql.io at NodePDX
 
What&rsquo;s new in Visual C++
What&rsquo;s new in Visual C++What&rsquo;s new in Visual C++
What&rsquo;s new in Visual C++
 
Kubernetes internals (Kubernetes 해부하기)
Kubernetes internals (Kubernetes 해부하기)Kubernetes internals (Kubernetes 해부하기)
Kubernetes internals (Kubernetes 해부하기)
 
Extending ns
Extending nsExtending ns
Extending ns
 
Build reliable, traceable, distributed systems with ZeroMQ
Build reliable, traceable, distributed systems with ZeroMQBuild reliable, traceable, distributed systems with ZeroMQ
Build reliable, traceable, distributed systems with ZeroMQ
 
RestMQ - HTTP/Redis based Message Queue
RestMQ - HTTP/Redis based Message QueueRestMQ - HTTP/Redis based Message Queue
RestMQ - HTTP/Redis based Message Queue
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 

A walk-through of the design and architecture of RabbitMQ - Ayanda Dube

  • 1. AYANDA DUBE ERLANG SOLUTIONS LTD RABBITMQ DESIGN & ARCHITECTURE 12/11/2018 Twitter: dube_aya Github: Ayanda-D Email: ayandaonline@gmail.com
  • 2. QUICK ADDITIONAL ACKNOWLEDGEMENTS ▸ Saskia Kuipers (ESL) ▸ Johan Rhodin and Lovisa Johansson (84codes) ▸ Pieter Humphrey (Pivotal) ▸ Pivotal Engineering Team for all the great work, as always! (Dan Carwin’s team) ▸ Everyone here, Erlang Solutions customers, some who’ve traveled from quite far
  • 3. GOAL: DESIGN & ARCHITECTURE P C ▸ Explain the internal design and architecture of rabbit APP-1 APP-2 ▸ Ever present need for efficient communication
  • 4. QUOTE "A picture is worth a thousand words" - Fred Barnard - Ayanda Dube …. (last night!) "A software system diagram is worth a thousand lines of code”
  • 8. INITIALIZATION: RABBIT BOOT MODULE RABBITMQ_BOOT_MODULE = rabbit rabbit:boot( )
  • 9. INITIALIZATION: BOOT rabbit boot! update application configs hipe compile initialise logging log hipe compile result prepare cluster status files upgrade mnesia check cluster consistency Broker Start! rabbitmq.config
  • 10. INITIALIZATION: BROKER START setup plugins start applications + plugins sd notify (“READY”) log broker started run boot steps
  • 11. INITIALIZATION: BOOT STEPS codec_correctness_check rabbit_alarm database (rabbit_mnesia) database_sync (mnesia_sync) file_handle_cache worker_pool rabbit_registry rabbit_core_metrics rabbit_memory_monitor guid_generator (rabbit_gui) delegate_sup (mnesia_sync) rabbit_node_monitor rabbit_epmd_monitor upgrade_queues recovery empty_db_check direct_client connection_tracking networking notify_cluster background_gc rabbit_core_metrics_gc rabbit_looking_glass internal boot steps kernel_ready external_infrastructure core_initialized routing_ready rabbit_event log_relay pre_boot plugin boot steps
  • 12. INITIALIZATION: INTERNAL BOOT STEPS auth mechanisms exchange types queue mirror modes policies (e.g. validators) queue master locators vhost limits priority queue runtime parameters enabled
  • 14. AMQP P C ▸ Connection establishment mnesia 5672 PLUGINS rabbit alarm rabbit reader rabbit memory monitor rabbit node monitor recovery file handle cache rabbit registry rabbit Sup worker pool rabbit epmd monitor delegate sup D=16 INITIALIZED APP-1 APP-2
  • 15. AMQP HANDLING: CONNECTION ESTABLISHMENT rabbit channel_0 5671P rabbit reader RANCH TCP connect 5672 rabbit writer rabbit connection sup ranch acceptor proc_lib #TCP Sock# connection.start connection.start_ok [login] connection.tune connection.tune_ok [login success] connection.open connection.open_ok assemble frame assemble frame assemble frame TCP AMQP #AMQP-Connection#
  • 16. AMQP HANDLING: CONNECTION ESTABLISHMENT rabbit reader main_loop receive messge(Socket) handle input handshake <<"AMQP", A, B, C, D, Rest/binary>> Aquire Framing Module {A, B, C, D} {0, 0, 9, 1} {1, 1, 0, 9} {1, 1, 8, 0} rabbit_framing_amqp_0_8 rabbit_framing_amqp_0_9_1 rabbit_framing_amqp_0_9_1 {1, 1, 8, 0} rabbit_framing_amqp_0_8 {ID, 1, 0, 0} rabbit_amqp1_0_reader start_connection AMQP 1.0 infrastructure register connection PID (pg_group) set server properties set auth mechanisms connection.start{ } send on channel 0 rabbit writer send command
  • 17. AMQP HANDLING: CONNECTION ESTABLISHMENT rabbit sup tcp_listener suptcp_listener ranch listener sup ranch conns sup ranch acceptors sup rabbit connection sup Protocol rabbit connection sup rabbit reader rabbit connection helper 10 ranch acceptor ProtocolPid rabbit reader recvloop(Socket) {active, once} mainloop recv handle_input FSM Transport:accept/2 CLIENT CONNECTION REQUESTS RANCH Started on BOOT
  • 18. AMQP HANDLING: NODE STATE P C ▸ Connection establishment ▸ Channel creation ch1 ch2 Ch3 ch1 ch2 ch3
  • 19. AMQP HANDLING: CHANNEL OPEN rabbit channel sup 5672 rabbit channel P rabbit reader channel.open rabbit channel common rabbit channel sup sup channel.open ChPid channel.open rabbit writer channel.open_ok
  • 20. AMQP HANDLING: CHANNEL OPEN rabbit reader receive loop(Socket) {active, once} handle input FSM Channel 0? Y handle method 0 process frame handle AMQP frame N lookup Channel ChPID rabbit_command assembler create new channel undefined ChannelMax? N rabbit_channel_sup_sup start_channel store ChPID (dictionary) {ch_pid, ChPid} {channel, Channel} Y ChannelCount + 1 Protocol decode_method_fields e.g. Protocol = rabbit_framing_amqp_0_9_1 rabbit_channel:do Method handle_cast( Method ) gen_server:cast/2 Method Update Channel State “running” Channel Created Stats ChPID
  • 21. AMQP HANDLING: CHANNEL OPEN rabbit channel sup sup rabbit channel sup rabbit limiter rabbit writer rabbit channel DIRECT NETWORK
  • 22. AMQP: NODE STATE P C ▸ Connection establishment ▸ Channel creation ▸ Create/declare an exchange ch2
  • 23. AMQP HANDLING: EXCHANGE DECLARATION 5672 rabbit channel P rabbit reader exchange.declare rabbit exchange exchange.declare_ok rabbit exchange type exchange.declare_ok direct fanout topic headers custom insert lookup {ok, X} not_found declare
  • 24. AMQP HANDLING: EXCHANGE DECLARATION rabbit channel exchange.declare valid type? Y N configure permitted? N Y lookup X {ok, X} {error, not_found} RETURN DECLARE MNESIAexchange.declare_ok exchange.declare_ok
  • 25. AMQP: NODE STATE ▸ Connection establishment P C ▸ Channel creation ▸ Create/declare an exchange ch2 ▸ Create/declare a queue
  • 26. AMQP HANDLING: QUEUE DECLARATION 5672 rabbit channel P queue.declare rabbit amqqueue queue.declare_ok rabbit queue process queue.declare_ok lookup {ok, Q} not_found queue stats [M, C] delegate stat backing queue queue.declare_ok nowait declare rabbit queue process sup init {new, Q} {ok, Q, 0, 0} BQ:len BQ:init [Q, Durable, AutoDelete, Args, …]
  • 27. AMQP HANDLING: QUEUE DECLARATION rabbit_amqque:declare queue.bind set policy queue master location mirroring queue master location node rabbit queue supervisor Node rabbit prequeue process Queue StartMode Slave Start Queue Master Start Queue Slave Master Q Initialize Queue Index Initiaze Message Store(s) Q ! {init, new} BQ:init initialization Transient Persistent
  • 28. AMQP: NODE STATE ▸ Connection establishment ▸ Channel creation ▸ Create/declare an exchange ▸ Create/declare a queue ▸ Bind queue to exchange P Cch2
  • 29. AMQP HANDLING: QUEUE TO EXCHANGE BINDING 5672 rabbit channel P queue.bind [Q, X] rabbit binding queue.bind_ok read [ _ ] [ ] add add(Q, X) rabbit_route rabbit_route rabbit_durable_route rabbit_semi_durable_route queue.bind_ok
  • 30. AMQP HANDLING: QUEUE TO EXCHANGE BINDING rabbit channel queue.bind format SRC & DST strip “n” and “r” resource names Y write permitted DST? Y N Is default X? N Y read permitted X? Y N RETURN rabbit_binding valid binding? N lookup binding [ _ ] Y [] INSERT BINDING MNESIA queue.bind_ok rabbit writer
  • 31. AMQP: NODE STATE ▸ Connection establishment ▸ Channel creation ▸ Declare an exchange ▸ Declare a queue ▸ Bind queue to exchange ▸ Subscribe Consumer P Cch2
  • 33. OPERATIONS: NODE STATE ▸ Connection establishment P C ▸ Channel creation ▸ Declare an exchange ch2 ▸ Declare a queue ▸ Bind queue to exchange ▸ Subscribe consumer ▸ Publish messages ch2 ch2 ch2
  • 34. AMQP HANDLING: MESSAGE PUBLISH rabbit channelP basic.publish rabbit queue process message route Queue(s) rabbit basic backing queue delivery rabbit exchange delegate #delivery [M, Queues] rabbit amqqueue #delivery{} rabbit queue consumer delivery_attempt is_duplicate? publish QPids
  • 35. AMQP HANDLING: BACKING QUEUE rabbit queue process backing queue rabbit queue index embed? publish rabbit queue msg store msg_store #msg_status{ } Transient Persistent or Internal BQ Queues store[ #msg_status ] Q1 [ALPHAs] Q2 [BETAS & GAMMAS] Q3 [BETAS & GAMMAS] Q4 [ALPHAs] ALPHA BETA GAMMA DELTA RAM MSG POS RAM DISK RAM DISK RAM & DISK DISK DISK #delivery{}
  • 36. AMQP: NODE STATE P Cch2 ch2 ch2 ch2 APP-1 APP-2
  • 37. OPERATIONS: CLUSTERING ▸ Adding “extra nodes” to mnesia configuration ▸ Replication and synchronisation of metadata ▸ Internal internode routing/referencing synch synch ▸ Default distribution port 25672
  • 38. OPERATIONS: HA QUEUES M S1 S2 gm gm gmC synch synch ▸ Backing queue switches to the mirror queue master GM ▸ HA policies dynamically update queue state ▸ Synchronisation over Erlang distribution
  • 39. CONCLUSION: DESIGN & ARCHITECTURE ▸ Not entirely fixed/static, common aspects ▸ Usage varies its internal design ▸ Creation and tearing down of resources (AMQP) ▸ Plugins will alter operation and design ▸ Version releases introduce design and architecture shifts https://github.com/rabbitmq/rabbitmq-server/ https://github.com/rabbitmq/rabbitmq-common/
  • 40. END: THANK YOU! QUESTIONS Twitter: dube_aya Github: Ayanda-D Email: ayandaonline@gmail.com