http://zero.mq/
A ØMQ socket is what you get when
you take a normal TCP socket, inject
it with a mix of radioactive isotopes
 stolen from a secret Soviet atomic
  research project, bombard it with
1950-era cosmic rays, and put it into
  the hands of a drug-addled comic
 book author with a badly-disguised
   fetish for bulging muscles clad in
 spandex. Yes, ØMQ sockets are the
    world-saving superheros of the
           networking world.
Problem
How to
    easy connect
any code to any code,
      anywhere
Existing solutions
Connect

• In-process in-proc://some-point
• Unix sockets ipc://some/pipe
• BSD sockets tcp://0.0.0.0:1234
• Others           multicast (PGM) ...
BSD Sockets
BSD   Protocols




        TCP       * Images by Tenouk
BSD    Protocols




               UDP

      TCP
                   * Images by Tenouk
BSD       Sockets

 • New/Exit - socket() , close()
 • Configure - setsockopt()
 • Connect - bind() , connect()
 • Use - send() , recv()
BSD    Problems


• Need to choice of transport
• Stream (TCP) , datagram (UDP)
• Peer-2-Peer connections
zguide.zero.mq
A ØMQ socket is what you get when
you take a normal TCP socket, inject
it with a mix of radioactive isotopes
 stolen from a secret Soviet atomic
  research project, bombard it with
1950-era cosmic rays, and put it into
  the hands of a drug-addled comic
 book author with a badly-disguised
   fetish for bulging muscles clad in
 spandex. Yes, ØMQ sockets are the
    world-saving superheros of the
           networking world.
in a Hundred Words
    ØMQ (ZeroMQ, 0MQ, zmq) looks like an embeddable
      networking library but acts like a concurrency
                           framework.
  It gives you sockets that carry whole messages across
various transports like in-process, inter-process, TCP, and
                            multicast.
 You can connect sockets N-to-N with patterns like
fanout, pub-sub, task distribution, and request-reply. It's fast
       enough to be the fabric for clustered products. Its
   asynchronous I/O model gives you scalable multicore
applications, built as asynchronous message-processing tasks.
          It has a score of language APIs and runs
                on most operating systems.
       ØMQ is from iMatix and is LGPL open source.
Many languages




           * Images by iMatrix
Sockets

•Well known API
•Messages oriented
• Transport agnostic
•Socket-level topology
Well known API
BSD     Sockets

 • New/Exit - socket()
 • Configure - setsockopt()
 • Connect - bind()
 • Use - send() , recv()
Sockets

• New/Exit - zmq_socket()
• Configure - zmq_setsockopt()
• Connect - zmq_bind()
• Use - zmq_send() , zmq_recv()
Hello world (server)
Hello world (client)
Message oriented
Message oriented
           Send




Receive
Various transports
Various transports



• req.bind(‘inproc://some/pipe’)
• req.bind(‘ipc://some/pipe’)
• req.bind(’tcp://127.0.0.1:5555’)
Patterns
Socket level topology
Request - Reply




             * Images by iMatrix
Publish - Subscribe




                * Images by iMatrix
Parallel tasks




             * Images by iMatrix
Demo
Scale
Start small




              * Images by iMatrix
Bigger




         * Images by iMatrix
And bigger...




                * Images by iMatrix
Devices




          Device



           * Images by iMatrix
QUEUE




        * Images by iMatrix
Demo
Implementation
Ruby-FFI
Foreign Function Interface
Ruby-FFI
Ruby-FFI (Win)
Why FFI?

•Debian: no need from *-dev

• Multi-platform

• Easy to read (Ruby, not C)
Projects
http://zeromq.org/docs:labs
http://mongrel2.org
Evolution
 App          App      App

 HTTP        HTTP     HTTP

 Net          Net      Net

Webrick     Mongrel   Thin
Evolution

            App

         HTTP

            Net

       Mongrel2
Mongrel2

Push/Pull      0mq        Pub/Sub

            Handler
                Handler             Responses
                      Handler
Requests
Demo
Future



• Part of Linux kernel
• http://www.crossroads.io/
• zerocloud ?
Thank you!

ZeroMQ