SlideShare ist ein Scribd-Unternehmen logo
1 von 18
Downloaden Sie, um offline zu lesen
Openstack Messaging
with ZMQ
(Distributed RPC)

By Yatin Kumbhare
yatinkumbhare@gmail.com
ZMQ / 0MQ / ZeroMQ -Introduction
●

Zero Broker, Zero latency, zero cost - culture of minimalism.

●

Brokerless - No SPOF

●

High Scalability

●

Flexible: inproc, ipc, tcp

●

Order of bind and connect - Doesn’t matter

●

Fast and reliable
REQ-REP
# Client
import zmq
context = zmq.Context()
print("Connecting to hello world server…")
socket = context.socket(zmq.REQ)
socket.connect("tcp://localhost:5555")
for request in range(10):
print("Sending request %s …" % request)
socket.send("Hello")
#

Get the reply.

message = socket.recv()
print("Received reply %s [ %s ]" %
(request, message))

# Server
import zmq
context = zmq.Context()
# Socket to talk to server
print("Connecting to hello world server…")
socket = context.socket(zmq.REP)
socket.bind("tcp://*:5555")
while True:
print("waiting for client request")
msg = socket.recv()
print("Message received %s “ % msg)
message = socket.send("World")
PUB-SUB
import zmq
from random import randint
context = zmq.Context()
socket = context.socket(zmq.PUB)
socket.bind("tcp://*:5556")

import zmq
import sys
context = zmq.Context()
socket = context.socket(zmq.SUB)
socket.connect("tcp://localhost:5556")

while True:
zipcode = randint(1, 10)
temperature = randint(-20, 50)

zip_filter = sys.argv[1] if len(sys.argv) > 1
else “”

humidity = randint(10, 15)
print “Publish data:”,(zipcode,
temperature, humidity)
socket.send("%d %d %d" % (zipcode,
temperature, relhumidity))

print “Collectin updates from weather service
%s” % zip_filter
socket.setsockopt(zmq.SUBSCRIBE, zip_filter)
#process 5 records
for record in range(5):
data = socket.recv()
print data
PUB-SUB
PUSH-PULL
# Ventilator
# socket to send messages on
sender = context.socket(zmq.PUSH)
sender.bind( “tcp://*:5557” )
sink = context.socket(zmq.PUSH)
sink.connect( “tcp://localhost:5558” )
sink.send( “0”)
# Workers:
receiver = context .socket(zmq .PULL)
receiver .connect( "tcp://localhost:5557" )
# Socket to send messages to to sink
sender = context .socket(zmq .PUSH)
sender.connect( "tcp://localhost:5558" )
# Sink:
# Socket to receive messages on
receiver = context .socket(zmq .PULL)
receiver .bind("tcp://*:5558" )
# Wait for start of batch
s = receiver .recv()
Single-Point-Failure
rpc.cast
rpc.call
ZMQ for Openstack
●

In openstack, zeromq makes use of two protocols, TCP and IPC.

●

TCP Socket, for sending message from nova services to rpc-zmq-receiver service.

●

IPC Socket, for forwarding message received by rpc-zmq-receiver to the local nova services, which is listening
on IPC socket.

●

ZMQ uses PUB-SUB and PUSH-PULL socket types.

●

PUB-SUB - to get reply, in case of rpc.call, this work as direct-consumer/publisher in context of rabbitmq.

●

PUSH-PULL - for sending messages to other services, for example rpc.cast.
zmq-receiver service
●

rpc-zmq-receiver service with different sockets.

●

Instantiate ZmqProxy class from oslo.messaging, impl_zmq.
py file.

●

Service creates TCP://*:9501, PULL socket, and listen for
messages from other services.

●

Topic: fanout~service or zmq_replies.<hostname>, zmq.PUB
socket

●

Topic: service.<hostname>, (conductor.node) zmq.PUSH socket
is created.

●

The socket protocol will be IPC.

●

Here, data is received on TCP://*:9501 and forwarded to IPC
socket.
Nova-* services
●

Instantiate ZmqReactor from oslo.messaging, impl_zmq.py
file.

●

Mostly the nova service manages with zmq.PUSH, zmq.PULL
and zmq.SUB socket type.

●

For consuming messages nova service uses IPC sockets with
zmq.PULL, and to cast a message it creates TCP, zmq.PUSH
socket.

●

example: when zmq-receiver, publish message on ipc:
///var/run/openstack/zmq_topic_conductor.node, with PUSH
socket, which is consumed by ipc:
///var/run/openstack/zmq_topic_conductor.node with PULL
socket at conductor service.
Nova-compute
●

topic: fanout~compute, bind to ipc:// , zmq.SUB socket

●

topic: compute.<hostname>, bind to ipc:// , zmq.PULL

●

nova compute does rpc.call on conductor at the start of the
service.

●

The hostname for conductor service is read out from
MatchMakerRing file.

●

compute service, creates tcp://<conductor-hostname>:9501,
PUSH socket and send message, which is received by zmqreceiver, and forwarded to nova-conductor service.

●

As, this is rpc.call, to receive reply, nova compute create, ipc:
///var/run/openstack/zmq_topic_zmq_replies.<hostname>
with SUB socket type and subscribe to msg-id (unique uuid),
and await for response from conductor.
MatchMakerRing file
{
"conductor": [
"controller"
],
"scheduler": [
"controller"
],
"compute": [
"controller","computenode"
],
"network": [
"controller","computenode"
],
"zmq_replies": [
"controller","computenode"
],

"cert": [
"controller"
],
"cinderscheduler": [
"controller"
],
"cinder-volume": [
"controller"
],
"consoleauth": [
"controller"
]
}
Message routing
compute make rpc.call to conductor.
Sends data on tcp://gravity:9501 with PUSH, which is received
by zmq-receiver service of gravity host with topic:conductor.
gravity

'conductor' {'args': {'service': {u'binary':
u'nova-compute',
u'created_at': u'2014-0219T11:02:32.000000',
u'deleted': 0,

before rpc.call, include following data
●
reply-topic as zmq_replies.nodex

u'deleted_at': None,

●

create unique msg_id,

u'disabled': False,

●

extra key "method":"-reply"

u'disabled_reason': None,
u'host': u'nodex',

To receive reply on topic:zmq_replies.nodex, creates socket
ipc://...zmq_topic_zmq_replies.nodex with SUB and subscribe to
msg_id.

u'id': 2,
u'report_count': 22,
u'topic': u'compute',

The conductor consume data and takes out reply-topic as
zmq_replies.nodex
Conductor sends back the response by creating tcp://nodex:
9501 with PUSH and send data.

u'updated_at': u'2014-0219T11:08:10.000000'},
'values': {'report_count': 23}},
'method': 'service_update',
'namespace': None,
'version': '1.34'}
Message routing
●

nodex zmq-receiver service, receiver data and
check for topic, based on topic which is

u'zmq_replies.nodex' {'args': {' msg_id':
u'103b95cc64ab4e39924b6240a8dbaac8',
'response': [[{'binary': u'nova-compute',

zmq_replies.nodex, create ipc://....
/zmq_topic_zmq_replies.nodex with PUB and

'created_at': '2014-0219T11:02:32.000000',

send data.
●

'deleted': 0L,

Now, the compute already has reply socket ipc://

'deleted_at': None,

with SUB, and is already subscribe to msg_id,

'disabled': False,

which will get back the response of rpc.call.

'disabled_reason': None,
'host': u'nodex',
'id': 2L,
'report_count': 23,
'topic': u'compute',
'updated_at': '2014-0219T11:08:33.572453'}]]},
'method': '-process_reply'}
Devstack with zmq
#localrc
●

ENABLED_SERVICES+=,-rabbit,-qpid,zeromq

●

#controller

ENABLED_SERVICES=n-cpu,n-net,zeromq

#compute node

Apply Patch: https://review.openstack.org/#/c/59875/3

Due to an issue with zeromq support for notifications in Glance, glance-api fails to start when configured to use
ZeroMQ.
Commnet line in lib/glance in devstack repository
#iniset_rpc_backend glance $GLANCE_API_CONF DEFAULT
Zmq in context of openstack

Weitere ähnliche Inhalte

Was ist angesagt?

ZeroMQ - Sockets on steroids!
ZeroMQ - Sockets on steroids!ZeroMQ - Sockets on steroids!
ZeroMQ - Sockets on steroids!Pedro Januário
 
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 ZeroMQRobin Xiao
 
Zeromq anatomy & jeromq
Zeromq anatomy & jeromqZeromq anatomy & jeromq
Zeromq anatomy & jeromqDongmin Yu
 
Distributed app development with nodejs and zeromq
Distributed app development with nodejs and zeromqDistributed app development with nodejs and zeromq
Distributed app development with nodejs and zeromqRuben Tan
 
FOSDEM 2011 - 0MQ
FOSDEM 2011 - 0MQFOSDEM 2011 - 0MQ
FOSDEM 2011 - 0MQpieterh
 
Leveraging zeromq for node.js
Leveraging zeromq for node.jsLeveraging zeromq for node.js
Leveraging zeromq for node.jsRuben Tan
 
Python Ireland 2012 - Message brokers and Python by Fernando Ciciliati
Python Ireland 2012 - Message brokers and Python by Fernando Ciciliati Python Ireland 2012 - Message brokers and Python by Fernando Ciciliati
Python Ireland 2012 - Message brokers and Python by Fernando Ciciliati Python Ireland
 
Netcat 101 by-mahesh-beema
Netcat 101 by-mahesh-beemaNetcat 101 by-mahesh-beema
Netcat 101 by-mahesh-beemaRaghunath G
 
sshuttle VPN (2011-04)
sshuttle VPN (2011-04)sshuttle VPN (2011-04)
sshuttle VPN (2011-04)apenwarr
 
2016-tcpkali-websocket
2016-tcpkali-websocket2016-tcpkali-websocket
2016-tcpkali-websocketLev Walkin
 
memcached Binary Protocol in a Nutshell
memcached Binary Protocol in a Nutshellmemcached Binary Protocol in a Nutshell
memcached Binary Protocol in a NutshellToru Maesaka
 
play framework async with scala
play framework async with scalaplay framework async with scala
play framework async with scalavuhaininh88
 
Tuning the Kernel for Varnish Cache
Tuning the Kernel for Varnish CacheTuning the Kernel for Varnish Cache
Tuning the Kernel for Varnish CachePer Buer
 
Stackless Python In Eve
Stackless Python In EveStackless Python In Eve
Stackless Python In Eveguest91855c
 
Building scalable network applications with Netty (as presented on NLJUG JFal...
Building scalable network applications with Netty (as presented on NLJUG JFal...Building scalable network applications with Netty (as presented on NLJUG JFal...
Building scalable network applications with Netty (as presented on NLJUG JFal...Jaap ter Woerds
 

Was ist angesagt? (20)

ZeroMQ - Sockets on steroids!
ZeroMQ - Sockets on steroids!ZeroMQ - Sockets on steroids!
ZeroMQ - Sockets on steroids!
 
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
 
ZeroMQ with NodeJS
ZeroMQ with NodeJSZeroMQ with NodeJS
ZeroMQ with NodeJS
 
Zeromq anatomy & jeromq
Zeromq anatomy & jeromqZeromq anatomy & jeromq
Zeromq anatomy & jeromq
 
Distributed app development with nodejs and zeromq
Distributed app development with nodejs and zeromqDistributed app development with nodejs and zeromq
Distributed app development with nodejs and zeromq
 
FOSDEM 2011 - 0MQ
FOSDEM 2011 - 0MQFOSDEM 2011 - 0MQ
FOSDEM 2011 - 0MQ
 
Leveraging zeromq for node.js
Leveraging zeromq for node.jsLeveraging zeromq for node.js
Leveraging zeromq for node.js
 
Python Ireland 2012 - Message brokers and Python by Fernando Ciciliati
Python Ireland 2012 - Message brokers and Python by Fernando Ciciliati Python Ireland 2012 - Message brokers and Python by Fernando Ciciliati
Python Ireland 2012 - Message brokers and Python by Fernando Ciciliati
 
Netcat 101 by-mahesh-beema
Netcat 101 by-mahesh-beemaNetcat 101 by-mahesh-beema
Netcat 101 by-mahesh-beema
 
sshuttle VPN (2011-04)
sshuttle VPN (2011-04)sshuttle VPN (2011-04)
sshuttle VPN (2011-04)
 
Rabbit MQ
Rabbit MQRabbit MQ
Rabbit MQ
 
2016-tcpkali-websocket
2016-tcpkali-websocket2016-tcpkali-websocket
2016-tcpkali-websocket
 
memcached Binary Protocol in a Nutshell
memcached Binary Protocol in a Nutshellmemcached Binary Protocol in a Nutshell
memcached Binary Protocol in a Nutshell
 
play framework async with scala
play framework async with scalaplay framework async with scala
play framework async with scala
 
PHP at Density and Scale
PHP at Density and ScalePHP at Density and Scale
PHP at Density and Scale
 
Building Netty Servers
Building Netty ServersBuilding Netty Servers
Building Netty Servers
 
Blocks, procs && lambdas
Blocks, procs && lambdasBlocks, procs && lambdas
Blocks, procs && lambdas
 
Tuning the Kernel for Varnish Cache
Tuning the Kernel for Varnish CacheTuning the Kernel for Varnish Cache
Tuning the Kernel for Varnish Cache
 
Stackless Python In Eve
Stackless Python In EveStackless Python In Eve
Stackless Python In Eve
 
Building scalable network applications with Netty (as presented on NLJUG JFal...
Building scalable network applications with Netty (as presented on NLJUG JFal...Building scalable network applications with Netty (as presented on NLJUG JFal...
Building scalable network applications with Netty (as presented on NLJUG JFal...
 

Andere mochten auch

Distributed RPC in Nova with ZeroMQ
Distributed RPC in Nova with ZeroMQDistributed RPC in Nova with ZeroMQ
Distributed RPC in Nova with ZeroMQRandy Bias
 
Сравнение AMQP и ZeroMQ
Сравнение AMQP и ZeroMQСравнение AMQP и ZeroMQ
Сравнение AMQP и ZeroMQMirantis
 
ZeroMQ e Redis: soluzioni open source per l'integrazione di componenti
ZeroMQ e Redis: soluzioni open source per l'integrazione di componentiZeroMQ e Redis: soluzioni open source per l'integrazione di componenti
ZeroMQ e Redis: soluzioni open source per l'integrazione di componentiMatteo Fortini
 
Software Architecture over ZeroMQ
Software Architecture over ZeroMQSoftware Architecture over ZeroMQ
Software Architecture over ZeroMQpieterh
 
ZeroMQ Is The Answer
ZeroMQ Is The AnswerZeroMQ Is The Answer
ZeroMQ Is The AnswerIan Barber
 
105指考成績人數累計
105指考成績人數累計105指考成績人數累計
105指考成績人數累計中 央社
 
Redis & ZeroMQ: How to scale your application
Redis & ZeroMQ: How to scale your applicationRedis & ZeroMQ: How to scale your application
Redis & ZeroMQ: How to scale your applicationrjsmelo
 

Andere mochten auch (8)

Distributed RPC in Nova with ZeroMQ
Distributed RPC in Nova with ZeroMQDistributed RPC in Nova with ZeroMQ
Distributed RPC in Nova with ZeroMQ
 
Сравнение AMQP и ZeroMQ
Сравнение AMQP и ZeroMQСравнение AMQP и ZeroMQ
Сравнение AMQP и ZeroMQ
 
Building UWP apps with React-Native
Building UWP apps with React-NativeBuilding UWP apps with React-Native
Building UWP apps with React-Native
 
ZeroMQ e Redis: soluzioni open source per l'integrazione di componenti
ZeroMQ e Redis: soluzioni open source per l'integrazione di componentiZeroMQ e Redis: soluzioni open source per l'integrazione di componenti
ZeroMQ e Redis: soluzioni open source per l'integrazione di componenti
 
Software Architecture over ZeroMQ
Software Architecture over ZeroMQSoftware Architecture over ZeroMQ
Software Architecture over ZeroMQ
 
ZeroMQ Is The Answer
ZeroMQ Is The AnswerZeroMQ Is The Answer
ZeroMQ Is The Answer
 
105指考成績人數累計
105指考成績人數累計105指考成績人數累計
105指考成績人數累計
 
Redis & ZeroMQ: How to scale your application
Redis & ZeroMQ: How to scale your applicationRedis & ZeroMQ: How to scale your application
Redis & ZeroMQ: How to scale your application
 

Ähnlich wie Zmq in context of openstack

Zeromq - Pycon India 2013
Zeromq - Pycon India 2013Zeromq - Pycon India 2013
Zeromq - Pycon India 2013Srinivasan R
 
CODE FOR echo_client.c A simple echo client using TCP #inc.pdf
CODE FOR echo_client.c A simple echo client using TCP  #inc.pdfCODE FOR echo_client.c A simple echo client using TCP  #inc.pdf
CODE FOR echo_client.c A simple echo client using TCP #inc.pdfsecunderbadtirumalgi
 
Network-Connected Development with ZeroMQ
Network-Connected Development with ZeroMQNetwork-Connected Development with ZeroMQ
Network-Connected Development with ZeroMQICS
 
Writing Networking Clients in Go - GopherCon 2017 talk
Writing Networking Clients in Go - GopherCon 2017 talkWriting Networking Clients in Go - GopherCon 2017 talk
Writing Networking Clients in Go - GopherCon 2017 talkNATS
 
GopherCon 2017 - Writing Networking Clients in Go: The Design & Implementati...
GopherCon 2017 -  Writing Networking Clients in Go: The Design & Implementati...GopherCon 2017 -  Writing Networking Clients in Go: The Design & Implementati...
GopherCon 2017 - Writing Networking Clients in Go: The Design & Implementati...wallyqs
 
Distributed Computing Patterns in R
Distributed Computing Patterns in RDistributed Computing Patterns in R
Distributed Computing Patterns in Rarmstrtw
 
Tornado Web Server Internals
Tornado Web Server InternalsTornado Web Server Internals
Tornado Web Server InternalsPraveen Gollakota
 
Oslo.Messaging new 0mq driver proposal
Oslo.Messaging new 0mq driver proposalOslo.Messaging new 0mq driver proposal
Oslo.Messaging new 0mq driver proposaldavanum
 
اسلاید اول جلسه یازدهم کلاس پایتون برای هکرهای قانونی
اسلاید اول جلسه یازدهم کلاس پایتون برای هکرهای قانونیاسلاید اول جلسه یازدهم کلاس پایتون برای هکرهای قانونی
اسلاید اول جلسه یازدهم کلاس پایتون برای هکرهای قانونیMohammad Reza Kamalifard
 
Socket programming using java
Socket programming using javaSocket programming using java
Socket programming using javaUC San Diego
 
Servers with Event Machine - David Troy - RailsConf 2011
Servers with Event Machine - David Troy - RailsConf 2011Servers with Event Machine - David Troy - RailsConf 2011
Servers with Event Machine - David Troy - RailsConf 2011David Troy
 

Ähnlich wie Zmq in context of openstack (20)

Zeromq - Pycon India 2013
Zeromq - Pycon India 2013Zeromq - Pycon India 2013
Zeromq - Pycon India 2013
 
20120521 - zeroMQ
20120521 - zeroMQ20120521 - zeroMQ
20120521 - zeroMQ
 
Npc08
Npc08Npc08
Npc08
 
CODE FOR echo_client.c A simple echo client using TCP #inc.pdf
CODE FOR echo_client.c A simple echo client using TCP  #inc.pdfCODE FOR echo_client.c A simple echo client using TCP  #inc.pdf
CODE FOR echo_client.c A simple echo client using TCP #inc.pdf
 
Network-Connected Development with ZeroMQ
Network-Connected Development with ZeroMQNetwork-Connected Development with ZeroMQ
Network-Connected Development with ZeroMQ
 
Python networking
Python networkingPython networking
Python networking
 
10 Networking
10 Networking10 Networking
10 Networking
 
#1 (TCPvs. UDP)
#1 (TCPvs. UDP)#1 (TCPvs. UDP)
#1 (TCPvs. UDP)
 
Socket programming
Socket programmingSocket programming
Socket programming
 
RabbitMQ in Sprayer
RabbitMQ in SprayerRabbitMQ in Sprayer
RabbitMQ in Sprayer
 
Writing Networking Clients in Go - GopherCon 2017 talk
Writing Networking Clients in Go - GopherCon 2017 talkWriting Networking Clients in Go - GopherCon 2017 talk
Writing Networking Clients in Go - GopherCon 2017 talk
 
GopherCon 2017 - Writing Networking Clients in Go: The Design & Implementati...
GopherCon 2017 -  Writing Networking Clients in Go: The Design & Implementati...GopherCon 2017 -  Writing Networking Clients in Go: The Design & Implementati...
GopherCon 2017 - Writing Networking Clients in Go: The Design & Implementati...
 
Distributed Computing Patterns in R
Distributed Computing Patterns in RDistributed Computing Patterns in R
Distributed Computing Patterns in R
 
Tornado Web Server Internals
Tornado Web Server InternalsTornado Web Server Internals
Tornado Web Server Internals
 
java networking
 java networking java networking
java networking
 
Oslo.Messaging new 0mq driver proposal
Oslo.Messaging new 0mq driver proposalOslo.Messaging new 0mq driver proposal
Oslo.Messaging new 0mq driver proposal
 
اسلاید اول جلسه یازدهم کلاس پایتون برای هکرهای قانونی
اسلاید اول جلسه یازدهم کلاس پایتون برای هکرهای قانونیاسلاید اول جلسه یازدهم کلاس پایتون برای هکرهای قانونی
اسلاید اول جلسه یازدهم کلاس پایتون برای هکرهای قانونی
 
Socket programming using java
Socket programming using javaSocket programming using java
Socket programming using java
 
Servers with Event Machine - David Troy - RailsConf 2011
Servers with Event Machine - David Troy - RailsConf 2011Servers with Event Machine - David Troy - RailsConf 2011
Servers with Event Machine - David Troy - RailsConf 2011
 
Netcat - 101 Swiss Army Knife
Netcat - 101 Swiss Army KnifeNetcat - 101 Swiss Army Knife
Netcat - 101 Swiss Army Knife
 

Kürzlich hochgeladen

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 ...apidays
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
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 FMESafe Software
 
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 FMESafe Software
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
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.pdfsudhanshuwaghmare1
 
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 2024Victor Rentea
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
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...Orbitshub
 
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...apidays
 
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 educationjfdjdjcjdnsjd
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
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...apidays
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 

Kürzlich hochgeladen (20)

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 ...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
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
 
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
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
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
 
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
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
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...
 
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
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
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...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 

Zmq in context of openstack

  • 1. Openstack Messaging with ZMQ (Distributed RPC) By Yatin Kumbhare yatinkumbhare@gmail.com
  • 2. ZMQ / 0MQ / ZeroMQ -Introduction ● Zero Broker, Zero latency, zero cost - culture of minimalism. ● Brokerless - No SPOF ● High Scalability ● Flexible: inproc, ipc, tcp ● Order of bind and connect - Doesn’t matter ● Fast and reliable
  • 3. REQ-REP # Client import zmq context = zmq.Context() print("Connecting to hello world server…") socket = context.socket(zmq.REQ) socket.connect("tcp://localhost:5555") for request in range(10): print("Sending request %s …" % request) socket.send("Hello") # Get the reply. message = socket.recv() print("Received reply %s [ %s ]" % (request, message)) # Server import zmq context = zmq.Context() # Socket to talk to server print("Connecting to hello world server…") socket = context.socket(zmq.REP) socket.bind("tcp://*:5555") while True: print("waiting for client request") msg = socket.recv() print("Message received %s “ % msg) message = socket.send("World")
  • 4. PUB-SUB import zmq from random import randint context = zmq.Context() socket = context.socket(zmq.PUB) socket.bind("tcp://*:5556") import zmq import sys context = zmq.Context() socket = context.socket(zmq.SUB) socket.connect("tcp://localhost:5556") while True: zipcode = randint(1, 10) temperature = randint(-20, 50) zip_filter = sys.argv[1] if len(sys.argv) > 1 else “” humidity = randint(10, 15) print “Publish data:”,(zipcode, temperature, humidity) socket.send("%d %d %d" % (zipcode, temperature, relhumidity)) print “Collectin updates from weather service %s” % zip_filter socket.setsockopt(zmq.SUBSCRIBE, zip_filter) #process 5 records for record in range(5): data = socket.recv() print data
  • 6. PUSH-PULL # Ventilator # socket to send messages on sender = context.socket(zmq.PUSH) sender.bind( “tcp://*:5557” ) sink = context.socket(zmq.PUSH) sink.connect( “tcp://localhost:5558” ) sink.send( “0”) # Workers: receiver = context .socket(zmq .PULL) receiver .connect( "tcp://localhost:5557" ) # Socket to send messages to to sink sender = context .socket(zmq .PUSH) sender.connect( "tcp://localhost:5558" ) # Sink: # Socket to receive messages on receiver = context .socket(zmq .PULL) receiver .bind("tcp://*:5558" ) # Wait for start of batch s = receiver .recv()
  • 10. ZMQ for Openstack ● In openstack, zeromq makes use of two protocols, TCP and IPC. ● TCP Socket, for sending message from nova services to rpc-zmq-receiver service. ● IPC Socket, for forwarding message received by rpc-zmq-receiver to the local nova services, which is listening on IPC socket. ● ZMQ uses PUB-SUB and PUSH-PULL socket types. ● PUB-SUB - to get reply, in case of rpc.call, this work as direct-consumer/publisher in context of rabbitmq. ● PUSH-PULL - for sending messages to other services, for example rpc.cast.
  • 11. zmq-receiver service ● rpc-zmq-receiver service with different sockets. ● Instantiate ZmqProxy class from oslo.messaging, impl_zmq. py file. ● Service creates TCP://*:9501, PULL socket, and listen for messages from other services. ● Topic: fanout~service or zmq_replies.<hostname>, zmq.PUB socket ● Topic: service.<hostname>, (conductor.node) zmq.PUSH socket is created. ● The socket protocol will be IPC. ● Here, data is received on TCP://*:9501 and forwarded to IPC socket.
  • 12. Nova-* services ● Instantiate ZmqReactor from oslo.messaging, impl_zmq.py file. ● Mostly the nova service manages with zmq.PUSH, zmq.PULL and zmq.SUB socket type. ● For consuming messages nova service uses IPC sockets with zmq.PULL, and to cast a message it creates TCP, zmq.PUSH socket. ● example: when zmq-receiver, publish message on ipc: ///var/run/openstack/zmq_topic_conductor.node, with PUSH socket, which is consumed by ipc: ///var/run/openstack/zmq_topic_conductor.node with PULL socket at conductor service.
  • 13. Nova-compute ● topic: fanout~compute, bind to ipc:// , zmq.SUB socket ● topic: compute.<hostname>, bind to ipc:// , zmq.PULL ● nova compute does rpc.call on conductor at the start of the service. ● The hostname for conductor service is read out from MatchMakerRing file. ● compute service, creates tcp://<conductor-hostname>:9501, PUSH socket and send message, which is received by zmqreceiver, and forwarded to nova-conductor service. ● As, this is rpc.call, to receive reply, nova compute create, ipc: ///var/run/openstack/zmq_topic_zmq_replies.<hostname> with SUB socket type and subscribe to msg-id (unique uuid), and await for response from conductor.
  • 14. MatchMakerRing file { "conductor": [ "controller" ], "scheduler": [ "controller" ], "compute": [ "controller","computenode" ], "network": [ "controller","computenode" ], "zmq_replies": [ "controller","computenode" ], "cert": [ "controller" ], "cinderscheduler": [ "controller" ], "cinder-volume": [ "controller" ], "consoleauth": [ "controller" ] }
  • 15. Message routing compute make rpc.call to conductor. Sends data on tcp://gravity:9501 with PUSH, which is received by zmq-receiver service of gravity host with topic:conductor. gravity 'conductor' {'args': {'service': {u'binary': u'nova-compute', u'created_at': u'2014-0219T11:02:32.000000', u'deleted': 0, before rpc.call, include following data ● reply-topic as zmq_replies.nodex u'deleted_at': None, ● create unique msg_id, u'disabled': False, ● extra key "method":"-reply" u'disabled_reason': None, u'host': u'nodex', To receive reply on topic:zmq_replies.nodex, creates socket ipc://...zmq_topic_zmq_replies.nodex with SUB and subscribe to msg_id. u'id': 2, u'report_count': 22, u'topic': u'compute', The conductor consume data and takes out reply-topic as zmq_replies.nodex Conductor sends back the response by creating tcp://nodex: 9501 with PUSH and send data. u'updated_at': u'2014-0219T11:08:10.000000'}, 'values': {'report_count': 23}}, 'method': 'service_update', 'namespace': None, 'version': '1.34'}
  • 16. Message routing ● nodex zmq-receiver service, receiver data and check for topic, based on topic which is u'zmq_replies.nodex' {'args': {' msg_id': u'103b95cc64ab4e39924b6240a8dbaac8', 'response': [[{'binary': u'nova-compute', zmq_replies.nodex, create ipc://.... /zmq_topic_zmq_replies.nodex with PUB and 'created_at': '2014-0219T11:02:32.000000', send data. ● 'deleted': 0L, Now, the compute already has reply socket ipc:// 'deleted_at': None, with SUB, and is already subscribe to msg_id, 'disabled': False, which will get back the response of rpc.call. 'disabled_reason': None, 'host': u'nodex', 'id': 2L, 'report_count': 23, 'topic': u'compute', 'updated_at': '2014-0219T11:08:33.572453'}]]}, 'method': '-process_reply'}
  • 17. Devstack with zmq #localrc ● ENABLED_SERVICES+=,-rabbit,-qpid,zeromq ● #controller ENABLED_SERVICES=n-cpu,n-net,zeromq #compute node Apply Patch: https://review.openstack.org/#/c/59875/3 Due to an issue with zeromq support for notifications in Glance, glance-api fails to start when configured to use ZeroMQ. Commnet line in lib/glance in devstack repository #iniset_rpc_backend glance $GLANCE_API_CONF DEFAULT