Upload
yihung-lee
View
1.511
Download
8
Embed Size (px)
DESCRIPTION
For 2013 micro sessions of CNA@CCU.
Citation preview
Introduction to ZeroMQ
Howard Lee2013/05/16
113年5月17⽇日星期五
AnnounceØMQ, ZeroMQ, and 0MQ used in this slides are trademarks of iMatix Corporation
ØMQ is copyright (c) Copyright (c) 2007-2012 iMatix Corporation and Contributors. ØMQ is free software licensed under the LGPL.
Above statements are referred from footer of its website
213年5月17⽇日星期五
Outline
Concept
Demo
Reference
313年5月17⽇日星期五
If you have known these, you will know what I say
Java, Ruby
Network programming
Multithread
Background knowledge
413年5月17⽇日星期五
Online chat room is a basic program for beginner of network programming
513年5月17⽇日星期五
How do you do when building a program of online chat-room for multi-players?
613年5月17⽇日星期五
Centralize-type Server
Client
ClientClient
713年5月17⽇日星期五
Good
What if the server broken......?
813年5月17⽇日星期五
-- Howard Lee said :p2013.05.16
Everything is important means nothing is important
913年5月17⽇日星期五
Everyone is a server means no one is a server
1013年5月17⽇日星期五
Client
ClientClient De-centralize
1113年5月17⽇日星期五
Previous page about de-centralize use many sockets
More sockets grow exponential when a client joins!
1213年5月17⽇日星期五
Here is
1313年5月17⽇日星期五
Apply scenarios above pages
It can do more!
We only pick up above two scenarios at today’s lightning session
1413年5月17⽇日星期五
Actor model
De-centralize --> zero broker
Distributed computing
Concept
1513年5月17⽇日星期五
Actor model in ZeroMQ
REQuest-REPly
PUBlish-SUBcribe
Pipeline
1613年5月17⽇日星期五
Actor model in ZeroMQ
One machine can play many actors simultaneously
Better scalability than data-centric distributed computing because easier to extend
1713年5月17⽇日星期五
REQuest-REPly
Reference:https://github.com/imatix/zguide/raw/master/images/fig2.png
After successfully connected,REQ and REP can start to act like
pin-pong
1813年5月17⽇日星期五
REQuest-REPlyOnly suite for demonstrating simple program of network chatting room to your TA with limited condition: pin-pong action. lol
You can design your own transmit strategy when speed of network aren’t stable for your file-transfer application according the time of response-received from other side.
1913年5月17⽇日星期五
PUBlish-SUBscribePublisher
PUB
SUBSubscriber
bind
Connect Connect
SUBSubscriber
SUBSubscriber
Connect
update
2013年5月17⽇日星期五
PUBlish-SUBscribe
Scenario: News feeds
Must explicitly assign subscribe condition: zmq_setsockopt
Auto delivered if they are connected successfully
2113年5月17⽇日星期五
PipelineAlways synchronize workers to start
load balancing from vent. to worker
fair-queuing: Sink collect data from workers
Reference: https://github.com/imatix/zguide/raw/master/images/fig5.png
2213年5月17⽇日星期五
Pipeline scenarios
Supercomputing
Wireless sensor network
...etc
2313年5月17⽇日星期五
Dealer
enhanced REQ
no restrict behaviors of send and receive
Router
Prepend identity of originator to message before passing it to another application
2413年5月17⽇日星期五
Example of Router and Dealer
Reference: https://github.com/imatix/zguide/raw/master/images/fig17.png
2513年5月17⽇日星期五
More actors model
Router
Dealer
Push
Pull
Pair
I won’t explain details today
2613年5月17⽇日星期五
Features2713年5月17⽇日星期五
De-centralized
Reference:https://github.com/imatix/zguide/raw/master/images/fig8.png
2813年5月17⽇日星期五
DistributedScalability
2913年5月17⽇日星期五
DistributedScalability
2913年5月17⽇日星期五
Sockets
IPC
Thread communication
TCP
Multicast
...etc
3013年5月17⽇日星期五
ZeroMQ CentralizedServer - REPly
Client - REQuest
Client - REQuest
3113年5月17⽇日星期五
AUto reconnect
First, clients issue request of connection
Later, server binds a port to reply the requests from clients
Centralize
3213年5月17⽇日星期五
AUto reconnect
First, clients issue request of connection
Later, server binds a port to reply the requests from clients
CentralizeStrange!
Not conventional
3213年5月17⽇日星期五
Demo
3313年5月17⽇日星期五
Code of REQ-REP
hwserver.rb
hwclient.rb
3413年5月17⽇日星期五
Demo REQ-REP
3513年5月17⽇日星期五
Code of PUB-SUB
wuserver.rb wuclient.rb
3613年5月17⽇日星期五
Demo PUB-SUB
3713年5月17⽇日星期五
Demo
Pipeline
taskvent.rb
taskwork.rb
tasksink.rb
3813年5月17⽇日星期五
More examples are here
https://github.com/imatix/zguide/tree/master/examples/
3913年5月17⽇日星期五
2011 SERN CERN comment ZeroMQ and other frameworks, which based on COBRA
http://www.zeromq.org/local--files/intro:read-the-manual/Middleware%20Trends%20and%20Market
%20Leaders%202011.pdf
4013年5月17⽇日星期五
Reference
Implementing Distributed Application using ZeroMQ http://www.slideshare.net/fcrippa/europycon2011-implementing-distributed-application-using-zeromq
Multithread magic http://www.slideshare.net/pieterh/fosdem-2011-0mq
4113年5月17⽇日星期五
Reference
Overview of ZeroMQ http://www.slideshare.net/pieterh/overview-of-zeromq
4213年5月17⽇日星期五
Question?
4313年5月17⽇日星期五
Multi-players chat room?
Leave it to you :p
4413年5月17⽇日星期五
FAQ
Get peer list?
No
4513年5月17⽇日星期五
Notice
These slides has presented in micro session CNA@CCU 2013
If I forgot to give a credit to you via referring your content, I will append it to reference page as soon as you notify me about that. :)
4613年5月17⽇日星期五