Giter Site home page Giter Site logo

meandthemoon / node-zmq-talk Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jimbojw/node-zmq-talk

0.0 1.0 0.0 282 KB

Building Distributed Systems with Node.js and ØMQ --- a talk for Node.js in the Wild

Home Page: https://www.youtube.com/watch?v=zgDjaJdAB9c

License: MIT License

JavaScript 100.00%

node-zmq-talk's Introduction

Building Distributed Systems with Node.js and ØMQ

VIDEO! Building Distributed Systems with Node.js and ØMQ

A talk for Node.js in the Wild

whoami

Talk Roadmap

  • Why ØMQ?
  • Installing ØMQ (skip)
  • Naive publish/subscribe using Sockets
  • PUB/SUB
  • REQ/REP
  • DEALER/ROUTER
  • PUSH/PULL
  • Questions?

Why ØMQ?

  • Distributed
  • Low latency, low-overhead
  • Event driven, non-blocking
  • Patterns!
  • Scalability / Philosophy of Ø

The Network Onion

  • Application, Presentation, Session
  • SSL, HTTP, SMTP, ØMQ
  • Transport --- TCP, UDP
  • Network --- IP
  • Data Link --- MAC
  • Physical --- wires

Installing ØMQ

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

Naive PUB/SUB with Sockets

Beacon application: fires an event once a second.

{
  "pid": 12345,
  "timestamp": 1404168475695
}

PUB program: net-beacon-pub.js

SUB program: net-beacon-sub.js

What's Wrong With That?

  • Listener bias.
  • Fault intolerant.
  • Leaky buffers.
  • Directionality (Publisher = Listener).

PUB/SUB with ØMQ

Same beacon application.

PUB program: zmq-beacon-pub.js

SUB program: zmq-beacon-sub.js

REQ/REP with ØMQ

Application requests the current time.

REP program: zmq-time-rep.js

REQ program: zmq-time-req.js

DEALER/ROUTER cluster with ØMQ

DEALER = parallel REQ

ROUTER = parallel REP

Figure of REP cluster using DEALER/ROUTER

Cluster responds to time requests just like the previous example.

REP cluster program: zmq-time-rep-cluster.js

PUSH/PULL with ZMQ

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

Wrap Up

  • Why ØMQ?
  • PUB/SUB
  • REQ/REP
  • DEALER/ROUTER
  • PUSH/PULL

Thank You!

For your kind attention.

Questions?

If there are any?

node-zmq-talk's People

Contributors

jimbojw avatar

Watchers

Matthew Henry avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.