SlideShare ist ein Scribd-Unternehmen logo
1 von 40
Downloaden Sie, um offline zu lesen
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 congs
hipe compile
initialise logging
log hipe compile result
prepare cluster status les
upgrade mnesia
check cluster consistency
Broker Start!
rabbitmq.cong
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)
le_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
undened
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

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

Introduction to kubernetes
Introduction to kubernetesIntroduction to kubernetes
Introduction to kubernetes
 
Deep Dive: AWS Command Line Interface
Deep Dive: AWS Command Line InterfaceDeep Dive: AWS Command Line Interface
Deep Dive: AWS Command Line Interface
 
Open shift 4 infra deep dive
Open shift 4    infra deep diveOpen shift 4    infra deep dive
Open shift 4 infra deep dive
 
Flexible, hybrid API-led software architectures with Kong
Flexible, hybrid API-led software architectures with KongFlexible, hybrid API-led software architectures with Kong
Flexible, hybrid API-led software architectures with Kong
 
Kubernetes Concepts And Architecture Powerpoint Presentation Slides
Kubernetes Concepts And Architecture Powerpoint Presentation SlidesKubernetes Concepts And Architecture Powerpoint Presentation Slides
Kubernetes Concepts And Architecture Powerpoint Presentation Slides
 
Platform Engineering
Platform EngineeringPlatform Engineering
Platform Engineering
 
OSMC 2022 | Ignite: Observability with Grafana & Prometheus for Kafka on Kube...
OSMC 2022 | Ignite: Observability with Grafana & Prometheus for Kafka on Kube...OSMC 2022 | Ignite: Observability with Grafana & Prometheus for Kafka on Kube...
OSMC 2022 | Ignite: Observability with Grafana & Prometheus for Kafka on Kube...
 
Terraform
TerraformTerraform
Terraform
 
En rhel-deploy-oracle-rac-database-12c-rhel-7
En rhel-deploy-oracle-rac-database-12c-rhel-7En rhel-deploy-oracle-rac-database-12c-rhel-7
En rhel-deploy-oracle-rac-database-12c-rhel-7
 
Kubernetes on AWS with Amazon EKS - MAD301 - New York AWS Summit
Kubernetes on AWS with Amazon EKS - MAD301 - New York AWS SummitKubernetes on AWS with Amazon EKS - MAD301 - New York AWS Summit
Kubernetes on AWS with Amazon EKS - MAD301 - New York AWS Summit
 
SRE Conference 2022 - How to Build a Healthy On-Call Culture
SRE Conference 2022 - How to Build a Healthy On-Call CultureSRE Conference 2022 - How to Build a Healthy On-Call Culture
SRE Conference 2022 - How to Build a Healthy On-Call Culture
 
Cross Data Center Replication with Redis using Redis Enterprise
Cross Data Center Replication with Redis using Redis EnterpriseCross Data Center Replication with Redis using Redis Enterprise
Cross Data Center Replication with Redis using Redis Enterprise
 
Kubernetes Summit 2021: Multi-Cluster - The Good, the Bad and the Ugly
Kubernetes Summit 2021: Multi-Cluster - The Good, the Bad and the UglyKubernetes Summit 2021: Multi-Cluster - The Good, the Bad and the Ugly
Kubernetes Summit 2021: Multi-Cluster - The Good, the Bad and the Ugly
 
Containers Anywhere with OpenShift by Red Hat
Containers Anywhere with OpenShift by Red HatContainers Anywhere with OpenShift by Red Hat
Containers Anywhere with OpenShift by Red Hat
 
Final terraform
Final terraformFinal terraform
Final terraform
 
Serverless Architecture Patterns
Serverless Architecture PatternsServerless Architecture Patterns
Serverless Architecture Patterns
 
Advanced Terraform
Advanced TerraformAdvanced Terraform
Advanced Terraform
 
Kubernetes in Docker
Kubernetes in DockerKubernetes in Docker
Kubernetes in Docker
 
infrastructure as code
infrastructure as codeinfrastructure as code
infrastructure as code
 
Kubernetes internals (Kubernetes 해부하기)
Kubernetes internals (Kubernetes 해부하기)Kubernetes internals (Kubernetes 해부하기)
Kubernetes internals (Kubernetes 해부하기)
 

Ähnlich wie 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
 
Extending ns
Extending nsExtending ns
Extending ns
yogiinmood
 

Ähnlich wie 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++
 
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
 
Scaling application with RabbitMQ
Scaling application with RabbitMQScaling application with RabbitMQ
Scaling application with RabbitMQ
 

KĂźrzlich hochgeladen

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

KĂźrzlich hochgeladen (20)

Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
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
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
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
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 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...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 

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 efcient 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 congs hipe compile initialise logging log hipe compile result prepare cluster status les upgrade mnesia check cluster consistency Broker Start! rabbitmq.cong
  • 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) le_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 undened 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 conguration ▸ 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 xed/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