Top Banner
CCA - NoDerivs 3.0 Unported License - Usage OK, no modifications, full attribution Distributed RPC in Nova with ZeroMQ X Image: http://ken.pepple.info/openstack/2011/04/22/openstack-nova-architecture/ 1 Tuesday, April 17, 12
52

Distributed RPC in Nova with ZeroMQ

May 17, 2015

Download

Technology

Randy Bias

Presentation deck from OpenStack Design Summit spring 2012 in San Francisco, by Eric Windisch.
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Distributed RPC in Nova with ZeroMQ

04-16-2012Distributed RPC with ZeroMQ: code & analysis

CCA - NoDerivs 3.0 Unported License - Usage OK, no modifications, full attributionCCA - NoDerivs 3.0 Unported License - Usage OK, no modifications, full attribution

Distributed RPC in Novawith ZeroMQ

X

Image: http://ken.pepple.info/openstack/2011/04/22/openstack-nova-architecture/

1

Tuesday, April 17, 12

Page 2: Distributed RPC in Nova with ZeroMQ

04-16-2012Distributed RPC with ZeroMQ: code & analysis

CCA - NoDerivs 3.0 Unported License - Usage OK, no modifications, full attributionCCA - NoDerivs 3.0 Unported License - Usage OK, no modifications, full attribution

Etherpad

2

http://etherpad.openstack.org/FolsomDistributedRPC

Tuesday, April 17, 12

Page 3: Distributed RPC in Nova with ZeroMQ

04-16-2012Distributed RPC with ZeroMQ: code & analysis

CCA - NoDerivs 3.0 Unported License - Usage OK, no modifications, full attributionCCA - NoDerivs 3.0 Unported License - Usage OK, no modifications, full attribution

@ewindisch

3

Tuesday, April 17, 12

Page 4: Distributed RPC in Nova with ZeroMQ

CCA - NoDerivs 3.0 Unported License - Usage OK, no modifications, full attribution

Etherpad

http://etherpad.openstack.org/FolsomDistributedRPC

Tuesday, April 17, 12

Page 5: Distributed RPC in Nova with ZeroMQ

04-16-2012Distributed RPC with ZeroMQ: code & analysis

CCA - NoDerivs 3.0 Unported License - Usage OK, no modifications, full attributionCCA - NoDerivs 3.0 Unported License - Usage OK, no modifications, full attribution

Brokered Messaging

Message QueueBroker

Application

5

Tuesday, April 17, 12

Page 6: Distributed RPC in Nova with ZeroMQ

04-16-2012Distributed RPC with ZeroMQ: code & analysis

CCA - NoDerivs 3.0 Unported License - Usage OK, no modifications, full attributionCCA - NoDerivs 3.0 Unported License - Usage OK, no modifications, full attribution

Brokered Messaging

Message QueueBroker

Application

X

5

Tuesday, April 17, 12

Page 7: Distributed RPC in Nova with ZeroMQ

CCA - NoDerivs 3.0 Unported License - Usage OK, no modifications, full attribution

Brokered Messaging

Message Queue

Application

Tuesday, April 17, 12

Page 8: Distributed RPC in Nova with ZeroMQ

CCA - NoDerivs 3.0 Unported License - Usage OK, no modifications, full attribution

Brokered Messaging

Application

Tuesday, April 17, 12

Page 9: Distributed RPC in Nova with ZeroMQ

CCA - NoDerivs 3.0 Unported License - Usage OK, no modifications, full attribution

High-Availability

HA Failover

Application

Tuesday, April 17, 12

Page 10: Distributed RPC in Nova with ZeroMQ

CCA - NoDerivs 3.0 Unported License - Usage OK, no modifications, full attribution

failover fails

Application

Tuesday, April 17, 12

Page 11: Distributed RPC in Nova with ZeroMQ

CCA - NoDerivs 3.0 Unported License - Usage OK, no modifications, full attribution

DecentralizedApplication

APINova Scheduler

Nova Network

Nova Compute

Message Queue

Message Queue

APINova Scheduler

Nova Network

Nova Compute

Tuesday, April 17, 12

Page 12: Distributed RPC in Nova with ZeroMQ

CCA - NoDerivs 3.0 Unported License - Usage OK, no modifications, full attribution

Tuesday, April 17, 12

Page 13: Distributed RPC in Nova with ZeroMQ

CCA - NoDerivs 3.0 Unported License - Usage OK, no modifications, full attribution

Tuesday, April 17, 12

Page 14: Distributed RPC in Nova with ZeroMQ

CCA - NoDerivs 3.0 Unported License - Usage OK, no modifications, full attribution

DecentralizedApplication

APINova Scheduler

Nova Network

Nova Compute

Message Queue

Message Queue

APINova Scheduler

Nova Network

Nova Compute

Tuesday, April 17, 12

Page 15: Distributed RPC in Nova with ZeroMQ

CCA - NoDerivs 3.0 Unported License - Usage OK, no modifications, full attribution

Decentralized

AbandonedMessages

Application

APINova Scheduler

Nova Network

Nova Compute

Message Queue

APINova Scheduler

Nova Network

Nova Compute

Tuesday, April 17, 12

Page 16: Distributed RPC in Nova with ZeroMQ

CCA - NoDerivs 3.0 Unported License - Usage OK, no modifications, full attribution

DecentralizedApplication

APINova Scheduler

Nova Network

Nova Compute

Message Queue

APINova Scheduler

Nova Network

Nova Compute

Tuesday, April 17, 12

Page 17: Distributed RPC in Nova with ZeroMQ

CCA - NoDerivs 3.0 Unported License - Usage OK, no modifications, full attribution

Solution:

Distributed RPCfor OpenStack Nova

Tuesday, April 17, 12

Page 18: Distributed RPC in Nova with ZeroMQ

CCA - NoDerivs 3.0 Unported License - Usage OK, no modifications, full attribution

Peer2Peer

Application

API

Nova Network

Nova Compute

Nova Network

Nova API

Nova Compute

Nova Scheduler

Tuesday, April 17, 12

Page 19: Distributed RPC in Nova with ZeroMQ

CCA - NoDerivs 3.0 Unported License - Usage OK, no modifications, full attribution

Peer2Peer

Application

API

Nova Network

Nova Compute

Nova Network

Nova API

Nova Compute

Tuesday, April 17, 12

Page 20: Distributed RPC in Nova with ZeroMQ

CCA - NoDerivs 3.0 Unported License - Usage OK, no modifications, full attribution

Peer2Peer

Application

API

Nova Network

Nova Compute

Nova Network

Nova API

Nova Compute

Nova Scheduler

Nova Scheduler

Tuesday, April 17, 12

Page 21: Distributed RPC in Nova with ZeroMQ

CCA - NoDerivs 3.0 Unported License - Usage OK, no modifications, full attribution

Peer2Peer

Application

API

Nova Network

Nova Compute

Nova Network

Nova API

Nova Compute

Nova Scheduler

Tuesday, April 17, 12

Page 22: Distributed RPC in Nova with ZeroMQ

CCA - NoDerivs 3.0 Unported License - Usage OK, no modifications, full attribution

rpc.cast(topic.host)

Invoker(e.g. api)

PublisherDirect Topic

Consumer

PUSH -> PULL

Worker(e.g. compute)

Cast to host.

Tuesday, April 17, 12

Page 23: Distributed RPC in Nova with ZeroMQ

CCA - NoDerivs 3.0 Unported License - Usage OK, no modifications, full attribution

rpc.cast(topic.host)

Invoker(e.g. api)

PublisherDirect Topic

Consumer

PUSH -> PULL

Worker(e.g. compute)

Cast to host.

Tuesday, April 17, 12

Page 24: Distributed RPC in Nova with ZeroMQ

CCA - NoDerivs 3.0 Unported License - Usage OK, no modifications, full attribution

rpc.cast(topic.host)

Invoker(e.g. api)

PublisherDirect Topic

Consumer

PUSH -> PULL

Worker(e.g. compute)

Reply.

Tuesday, April 17, 12

Page 25: Distributed RPC in Nova with ZeroMQ

CCA - NoDerivs 3.0 Unported License - Usage OK, no modifications, full attribution

rpc.cast(topic.host)

Invoker(e.g. api)

PublisherDirect Topic

Consumer

PUSH -> PULL

Worker(e.g. compute)

Reply.

Tuesday, April 17, 12

Page 26: Distributed RPC in Nova with ZeroMQ

def _send(...):

“”” code omitted “””

# Curry the original request into a reply method.

orig_payload = [RpcContext.marshal(context), msg]

payload = [RpcContext.marshal(context), {

'method': '-reply', # Send original call to wrapper

'args': {

'msg_id': msg_id,

'context': RpcContext.marshal(context),

'topic': reply_topic, # our return path

'msg': orig_payload

}

}]

Tuesday, April 17, 12

Page 27: Distributed RPC in Nova with ZeroMQ

# Messages arriving async.

msg_waiter = QueueSocket(

"ipc:///var/run/nova/zmq_reply_queue",

zmq.SUB, subscribe=msg_id, bind=False)

try:

with Timeout(timeout):

with Timeout(30) as t1:

conn.cast(msg_id, topic, payload)

# Blocks until receives reply

responses = pickle.loads(msg_waiter.recv()[-1])

Tuesday, April 17, 12

Page 28: Distributed RPC in Nova with ZeroMQ

def reply(...): # this is -reply

"""Reply to a casted call"""

child_ctx = RpcContext.unmarshal(orig_payload[0])

response = ConsumerBase.normalize_reply(

self.get_response( # execute original call

child_ctx, proxy, topic, orig_payload[1]),

ctx.replies

)

_multi_send("cast", ctx, reply_topic, {

'method': '-process_reply',

'args': {

'msg_id': msg_id,

'response': response

}

})

Tuesday, April 17, 12

Page 29: Distributed RPC in Nova with ZeroMQ

def process_reply(...):

"""Process a reply"""

# zmq_replies is the receiver service

self.msg_waiter.cast(str(msg_id), str('zmq_replies'), response)

Tuesday, April 17, 12

Page 30: Distributed RPC in Nova with ZeroMQ

CCA - NoDerivs 3.0 Unported License - Usage OK, no modifications, full attribution

rpc.call(topic.worker)

Invoker(e.g. api)

PublisherDirect Topic

Consumer

PUSH->PULLcurries reply method

PULL<-PUSHrpc.cast -process_reply() Worker

(e.g. compute.host)

Call method.

Tuesday, April 17, 12

Page 31: Distributed RPC in Nova with ZeroMQ

CCA - NoDerivs 3.0 Unported License - Usage OK, no modifications, full attribution

rpc.call(topic.worker)

Invoker(e.g. api)

PublisherDirect Topic

Consumer

PUSH->PULLcurries reply method

PULL<-PUSHrpc.cast -process_reply() Worker

(e.g. compute.host)

Call method.

Tuesday, April 17, 12

Page 32: Distributed RPC in Nova with ZeroMQ

CCA - NoDerivs 3.0 Unported License - Usage OK, no modifications, full attribution

rpc.call(topic.worker)

Invoker(e.g. api)

PublisherDirect Topic

Consumer

PUSH->PULLcurries reply method

PULL<-PUSHrpc.cast -process_reply() Worker

(e.g. compute.host)

Call method.

Tuesday, April 17, 12

Page 33: Distributed RPC in Nova with ZeroMQ

CCA - NoDerivs 3.0 Unported License - Usage OK, no modifications, full attribution

rpc.call(topic.worker)

Invoker(e.g. api)

PublisherDirect Topic

Consumer

PUSH->PULLcurries reply method

PULL<-PUSHrpc.cast -process_reply() Worker

(e.g. compute.host)

Call method.

Tuesday, April 17, 12

Page 34: Distributed RPC in Nova with ZeroMQ

CCA - NoDerivs 3.0 Unported License - Usage OK, no modifications, full attribution

“scheduler.host1” goes to “host1”

Where do messages for “scheduler” go?

Bare Topics

Tuesday, April 17, 12

Page 35: Distributed RPC in Nova with ZeroMQ

CCA - NoDerivs 3.0 Unported License - Usage OK, no modifications, full attribution

MatchMaking

Tuesday, April 17, 12

Page 36: Distributed RPC in Nova with ZeroMQ

CCA - NoDerivs 3.0 Unported License - Usage OK, no modifications, full attribution

RewriteEngine• Every incoming topic is

mapped to an array of topics and hosts.

• Usually returns a single topic/host.

Tuesday, April 17, 12

Page 37: Distributed RPC in Nova with ZeroMQ

CCA - NoDerivs 3.0 Unported License - Usage OK, no modifications, full attribution

Search for hosts

• Can be provided by:

• hash table (implemented)

• name service (i.e. DNS)

• directory service (i.e. LDAP)

• zookeeper

• etc...

Tuesday, April 17, 12

Page 38: Distributed RPC in Nova with ZeroMQ

CCA - NoDerivs 3.0 Unported License - Usage OK, no modifications, full attribution

rpc.fanout_cast(topic)e.g. "compute"

Invoker(e.g. api)

PublisherDirect Topic

ConsumerPUSH -> PULLi.e. rpc.cast(topic.worker)

Worker(e.g. nova-compute on

compute.host)

MatchMaker

get_workersas workers

for each worker:

Fanout may have many workers.

Array *topic.worker

Fanout Cast.Tuesday, April 17, 12

Page 39: Distributed RPC in Nova with ZeroMQ

CCA - NoDerivs 3.0 Unported License - Usage OK, no modifications, full attribution

rpc.fanout_cast(topic)e.g. "compute"

Invoker(e.g. api)

PublisherDirect Topic

ConsumerPUSH -> PULLi.e. rpc.cast(topic.worker)

Worker(e.g. nova-compute on

compute.host)

MatchMaker

get_workersas workers

for each worker:

Fanout may have many workers.

Array *topic.worker

Fanout Cast.Tuesday, April 17, 12

Page 40: Distributed RPC in Nova with ZeroMQ

CCA - NoDerivs 3.0 Unported License - Usage OK, no modifications, full attribution

rpc.fanout_cast(topic)e.g. "compute"

Invoker(e.g. api)

PublisherDirect Topic

ConsumerPUSH -> PULLi.e. rpc.cast(topic.worker)

Worker(e.g. nova-compute on

compute.host)

MatchMaker

get_workersas workers

for each worker:

Fanout may have many workers.

Array *topic.worker

Fanout Cast.Tuesday, April 17, 12

Page 41: Distributed RPC in Nova with ZeroMQ

CCA - NoDerivs 3.0 Unported License - Usage OK, no modifications, full attribution

rpc.fanout_cast(topic)e.g. "compute"

Invoker(e.g. api)

PublisherDirect Topic

ConsumerPUSH -> PULLi.e. rpc.cast(topic.worker)

Worker(e.g. nova-compute on

compute.host)

MatchMaker

get_workersas workers

for each worker:

Fanout may have many workers.

Array *topic.worker

Fanout Cast.Tuesday, April 17, 12

Page 42: Distributed RPC in Nova with ZeroMQ

CCA - NoDerivs 3.0 Unported License - Usage OK, no modifications, full attribution

rpc.fanout_cast(topic)e.g. "compute"

Invoker(e.g. api)

PublisherDirect Topic

ConsumerPUSH -> PULLi.e. rpc.cast(topic.worker)

Worker(e.g. nova-compute on

compute.host)

MatchMaker

get_workersas workers

for each worker:

Fanout may have many workers.

Array *topic.worker

Fanout Cast.Tuesday, April 17, 12

Page 43: Distributed RPC in Nova with ZeroMQ

CCA - NoDerivs 3.0 Unported License - Usage OK, no modifications, full attribution

rpc.fanout_cast(topic)e.g. "compute"

Invoker(e.g. api)

PublisherDirect Topic

ConsumerPUSH -> PULLi.e. rpc.cast(topic.worker)

Worker(e.g. nova-compute on

compute.host)

MatchMaker

get_workersas workers

for each worker:

Fanout may have many workers.

Array *topic.worker

Fanout Cast.Tuesday, April 17, 12

Page 44: Distributed RPC in Nova with ZeroMQ

CCA - NoDerivs 3.0 Unported License - Usage OK, no modifications, full attribution

rpc.fanout_cast(topic)e.g. "compute"

Invoker(e.g. api)

PublisherDirect Topic

ConsumerPUSH -> PULLi.e. rpc.cast(topic.worker)

Worker(e.g. nova-compute on

compute.host)

MatchMaker

get_workersas workers

for each worker:

Fanout may have many workers.

Array *topic.worker

Fanout Cast.Tuesday, April 17, 12

Page 45: Distributed RPC in Nova with ZeroMQ

CCA - NoDerivs 3.0 Unported License - Usage OK, no modifications, full attribution

rpc.fanout_cast(topic)e.g. "compute"

Invoker(e.g. api)

PublisherDirect Topic

ConsumerPUSH -> PULLi.e. rpc.cast(topic.worker)

Worker(e.g. nova-compute on

compute.host)

MatchMaker

get_workersas workers

for each worker:

Fanout may have many workers.

Array *topic.worker

Fanout Cast.Tuesday, April 17, 12

Page 46: Distributed RPC in Nova with ZeroMQ

CCA - NoDerivs 3.0 Unported License - Usage OK, no modifications, full attribution

rpc.fanout_cast(topic)e.g. "compute"

Invoker(e.g. api)

PublisherDirect Topic

ConsumerPUSH -> PULLi.e. rpc.cast(topic.worker)

Worker(e.g. nova-compute on

compute.host)

MatchMaker

get_workersas workers

for each worker:

Fanout may have many workers.

Array *topic.worker

Fanout Cast.Tuesday, April 17, 12

Page 47: Distributed RPC in Nova with ZeroMQ

CCA - NoDerivs 3.0 Unported License - Usage OK, no modifications, full attribution

rpc.fanout_cast(topic)e.g. "compute"

Invoker(e.g. api)

PublisherDirect Topic

ConsumerPUSH -> PULLi.e. rpc.cast(topic.worker)

Worker(e.g. nova-compute on

compute.host)

MatchMaker

get_workersas workers

for each worker:

Fanout may have many workers.

Array *topic.worker

Fanout Cast.Tuesday, April 17, 12

Page 48: Distributed RPC in Nova with ZeroMQ

CCA - NoDerivs 3.0 Unported License - Usage OK, no modifications, full attribution

rpc.fanout_cast(topic)e.g. "compute"

Invoker(e.g. api)

PublisherDirect Topic

ConsumerPUSH -> PULLi.e. rpc.cast(topic.worker)

Worker(e.g. nova-compute on

compute.host)

MatchMaker

get_workersas workers

for each worker:

Fanout may have many workers.

Array *topic.worker

Fanout Cast.Tuesday, April 17, 12

Page 49: Distributed RPC in Nova with ZeroMQ

CCA - NoDerivs 3.0 Unported License - Usage OK, no modifications, full attribution

http://amitpiplani.blogspot.com/2010/05/u-pick-2-selection-for-nosql-providers.htmlhttp://amitpiplani.blogspot.com/2010/05/u-pick-2-selection-for-nosql-providers.html

Tuesday, April 17, 12

Page 50: Distributed RPC in Nova with ZeroMQ

CCA - NoDerivs 3.0 Unported License - Usage OK, no modifications, full attribution

http://amitpiplani.blogspot.com/2010/05/u-pick-2-selection-for-nosql-providers.htmlhttp://amitpiplani.blogspot.com/2010/05/u-pick-2-selection-for-nosql-providers.html

Tuesday, April 17, 12

Page 51: Distributed RPC in Nova with ZeroMQ

CCA - NoDerivs 3.0 Unported License - Usage OK, no modifications, full attribution

http://amitpiplani.blogspot.com/2010/05/u-pick-2-selection-for-nosql-providers.htmlhttp://amitpiplani.blogspot.com/2010/05/u-pick-2-selection-for-nosql-providers.html

NOVARPC

Tuesday, April 17, 12

Page 52: Distributed RPC in Nova with ZeroMQ

CCA - NoDerivs 3.0 Unported License - Usage OK, no modifications, full attribution

Thank You

Slide deck:

http://bit.ly/HJogQ8

Essex Plug-in Download

https://github.com/cloudscaling/nova-mq

Tuesday, April 17, 12