Distributed Computing with JavaScript

Presented by Dan Silvestru and Gord Tanner
bithound.io / @bithoundio

computering is hard!

Who are we?

bithound.io


Lasers!

What do we do?



We help you build and deliver the best quality software, every single day!

Problem:


                      > time jshint .

                      ---------------------
                      (lots of errors here)
                      ---------------------

                      7368 errors

                      real  0m29.321s
                      user  0m28.627s
                      sys 0m0.508s

          
- Do this for 1K+ commits in a project
- There are many more things to look at

Waiting sucks

but....

cluster

To the Cloud!

ØMQ looks like an embeddable networking library but acts like a concurrency framework.
                  .------------.        .--------------.
                  |            |        |              |
                  | TCP socket +------->|              | ZAP!
                  |            | BOOM!  |  0MQ socket  |
                  '------------'        |              |  POW!!
                    ^    ^    ^         |              |
                    |    |    |         '--------------'
                    |    |    |
                    |    |    |
                    |    |    '--------- Spandex
                    |    |
                    |    '-------------- Cosmic rays

                   Illegal radioisotopes from
                   secret Soviet atomic city
          

Sockets that carry atomic messages across various transports like:

  • in-process
  • inter-process (shared memory)
  • TCP
  • multicast

You can connect sockets N-to-N with patterns like

  • fan-out, fan-in
  • publish-subscribe
  • task distribution
  • request-reply
                                #------------#
                                |   Client   |
                                +------------+
                                |    REQ     |
                                '---+--------'
                                    |    ^
                                    |    |
                              Hello |    | World
                                    |    |
                                    v    |
                                .--------+---.
                                |    REP     |
                                +------------+
                                |   Server   |
                                #------------#
            
          
                               #-------------#
                               |  Publisher  |
                               +-------------+
                               |     PUB     |
                               '-------------'
                                    bind
                                      |
                                      |
                                   updates
                                      |
                      .---------------+---------------.
                      |               |               |
                   updates         updates         updates
                      |               |               |
                      |               |               |
                      v               v               v
                   connect         connect         connect
                .------------.  .------------.  .------------.
                |    SUB     |  |    SUB     |  |    SUB     |
                +------------+  +------------+  +------------+
                | Subscriber |  | Subscriber |  | Subscriber |
                #------------#  #------------#  #------------#

          
                                #-------------#
                                |  Ventilator |
                                +-------------+
                                |    PUSH     |
                                '------+------'
                                       |
                                     tasks
                                       |
                          .------------+-------------.
                          |            |             |
                          v            v             v
                    .----------.  .----------.  .----------.
                    |   PULL   |  |   PULL   |  |   PULL   |
                    +----------+  +----------+  +----------+
                    |  Worker  |  |  Worker  |  |  Worker  |
                    +----------+  +----------+  +----------+
                    |   PUSH   |  |   PUSH   |  |   PUSH   |
                    '----+-----'  '----+-----'  '----+-----'
                          |            |             |
                          '------------+-------------'
                                       |
                                    results
                                       |
                                       v
                                .-------------.
                                |    PULL     |
                                +-------------+
                                |    Sink     |
                                #-------------#
          

Codez

Her: "How many letters are in 10?"

Me: "three, why?"

  • ten has 3 letters

  • three has 5 letters

  • five has 4 letters

  • four has 4 letters

  • that works

4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 
If you do have zmq installed ...

http://zeromq.org/intro:get-the-software

May the fours be with you
                              npm install fourism
                      http://github.com/gtanner/fourism
          

Thank you!

bithound.io/preview



bithound.io / @bithoundio