VIDEO! Building Distributed Systems with Node.js and ØMQ
A talk for Node.js in the Wild
- Jim R. Wilson
- author: Node.js the Right Way (on Amazon)
- github: jimbojw
- twitter: @hexlib
- Why ØMQ?
- Installing ØMQ (skip)
- Naive publish/subscribe using Sockets
- PUB/SUB
- REQ/REP
- DEALER/ROUTER
- PUSH/PULL
- Questions?
- Distributed
- Low latency, low-overhead
- Event driven, non-blocking
- Patterns!
- Scalability / Philosophy of Ø
- Application, Presentation, Session
- SSL, HTTP, SMTP, ØMQ
- Transport --- TCP, UDP
- Network --- IP
- Data Link --- MAC
- Physical --- wires
Mac OSX
brew install zmq
Ubuntu
sudo apt-get install libtool autoconf automake uuid-dev build-essential
wget http://download.zeromq.org/zeromq-3.2.2.tar.gz
tar zxvf zeromq-3.2.2.tar.gz && cd zeromq-3.2.2
./configure
make
sudo make install
Testing the base library.
man zmq
Install the zmq node module.
npm install zmq
Testing the module.
node --harmony -p -e 'require("zmq")'
First pass at troubleshooting (update system library cache):
sudo ldconfig
Beacon application: fires an event once a second.
{
"pid": 12345,
"timestamp": 1404168475695
}
PUB program: net-beacon-pub.js
SUB program: net-beacon-sub.js
- Listener bias.
- Fault intolerant.
- Leaky buffers.
- Directionality (Publisher = Listener).
Same beacon application.
PUB program: zmq-beacon-pub.js
SUB program: zmq-beacon-sub.js
Application requests the current time.
REP program: zmq-time-rep.js
REQ program: zmq-time-req.js
DEALER = parallel REQ
ROUTER = parallel REP
Cluster responds to time requests just like the previous example.
REP cluster program: zmq-time-rep-cluster.js
Simple work queue using PUSH/PULL.
PUSH program: zmq-work-push.js
PULL program: zmq-work-pull.js
Cluster to demonstrate the First Joiner problem.
PULL cluster program: zmq-work-pull-cluster.js
- Why ØMQ?
- PUB/SUB
- REQ/REP
- DEALER/ROUTER
- PUSH/PULL
For your kind attention.
If there are any?