NullMQ @ PDX

64
Null MQ ZEROMQ SEMANTICS IN THE BROWSER Jeff Lindsay @progrium Bulat Shakirzyanov @avalanche123

description

 

Transcript of NullMQ @ PDX

Page 1: NullMQ @ PDX

NullMQZEROMQ SEMANTICS IN THE BROWSER

Jeff Lindsay@progrium

Bulat Shakirzyanov@avalanche123

Page 2: NullMQ @ PDX
Page 3: NullMQ @ PDX
Page 4: NullMQ @ PDX

libzmq

Page 5: NullMQ @ PDX

libzmq

High-level patterns

Page 6: NullMQ @ PDX

libzmq

High-level patterns

Philosophy

Page 7: NullMQ @ PDX

libzmq

High-level patterns

Philosophy

Page 8: NullMQ @ PDX

libzmq

High-level patterns

Philosophy

API / Semantics

Page 9: NullMQ @ PDX

Toolkit for building messaging systems...

Page 10: NullMQ @ PDX

Toolkit for building messaging systems...

...behind your firewall

Page 11: NullMQ @ PDX

Toolkit for building messaging systems...

...behind your firewall

...not for customers

Page 12: NullMQ @ PDX

Toolkit for building messaging systems...

...behind your firewall

...not for customers

...certainly not with the browser

Page 13: NullMQ @ PDX

BUILDAPPS THAT COMMUNICATEWITH VOICE & SMS

twilio is a RESTful API for making & receiving voice calls over phones and VOIP, as well as sending & receiving text messages.

Using your existing web languages and infrastructure, you can build phone, SMS, and VOIP into your apps.

With just a single line of code, you can make the phone in your pocket ring.

Get started now with a free trial:

www2.twilio.com/pycon2012

MAKE & RECEIVEPHONE CALLS

SEND & RECEIVETEXT MESSAGES

INSTANTLY BUYPHONE NUMBERS

ADD VOICE TOWEB & MOBILE APPS

Page 14: NullMQ @ PDX
Page 15: NullMQ @ PDX
Page 16: NullMQ @ PDX
Page 17: NullMQ @ PDX

Browser Browser

Page 18: NullMQ @ PDX

ZeroMQ in the browser?

Page 19: NullMQ @ PDX

ZeroMQ in the browser?

• libzmq is a C++ library

Page 20: NullMQ @ PDX

ZeroMQ in the browser?

• libzmq is a C++ library

• Browser extension not viable

Page 21: NullMQ @ PDX

ZeroMQ in the browser?

• libzmq is a C++ library

• Browser extension not viable

• ZMTP is not valuable by itself

Page 22: NullMQ @ PDX

Let’s say we did...

Page 23: NullMQ @ PDX

• Security?

Let’s say we did...

Page 24: NullMQ @ PDX

• Security?

• Skip existing auth infrastructure

Let’s say we did...

Page 25: NullMQ @ PDX

• Security?

• Skip existing auth infrastructure

• Need to make something up

Let’s say we did...

Page 26: NullMQ @ PDX

• Security?

• Skip existing auth infrastructure

• Need to make something up

• Direct connections?

Let’s say we did...

Page 27: NullMQ @ PDX

• Security?

• Skip existing auth infrastructure

• Need to make something up

• Direct connections?

• Lots of open connections, open ports

Let’s say we did...

Page 28: NullMQ @ PDX

• Security?

• Skip existing auth infrastructure

• Need to make something up

• Direct connections?

• Lots of open connections, open ports

• Just not “web friendly”

Let’s say we did...

Page 29: NullMQ @ PDX

libzmq

High-level patterns

Philosophy

API / Semantics

Page 30: NullMQ @ PDX

libzmq

High-level patterns

Philosophy

API / SemanticsAPI / Semantics

Page 31: NullMQ @ PDX

What do we want?

Page 32: NullMQ @ PDX

What do we want?

• Near feature/semantic parity with ZeroMQ

Page 33: NullMQ @ PDX

What do we want?

• Near feature/semantic parity with ZeroMQ

• Throughput performance not as important

Page 34: NullMQ @ PDX

What do we want?

• Near feature/semantic parity with ZeroMQ

• Throughput performance not as important

• Embrace nature of the web in design

Page 35: NullMQ @ PDX

What do we want?

• Near feature/semantic parity with ZeroMQ

• Throughput performance not as important

• Embrace nature of the web in design

• Single connection, service multiplexing

Page 36: NullMQ @ PDX

What do we want?

• Near feature/semantic parity with ZeroMQ

• Throughput performance not as important

• Embrace nature of the web in design

• Single connection, service multiplexing

• Use existing transports, protocols, etc

Page 37: NullMQ @ PDX

What do we want?

• Near feature/semantic parity with ZeroMQ

• Throughput performance not as important

• Embrace nature of the web in design

• Single connection, service multiplexing

• Use existing transports, protocols, etc

NullMQ

Page 38: NullMQ @ PDX

What do we have?

Page 39: NullMQ @ PDX

WebSocket

Page 40: NullMQ @ PDX

WebSocket

• ZMTP over WebSocket?

Page 41: NullMQ @ PDX

WebSocket

• ZMTP over WebSocket?

• Connection inefficient

Page 42: NullMQ @ PDX

WebSocket

• ZMTP over WebSocket?

• Connection inefficient

• Not extensible

Page 43: NullMQ @ PDX

WebSocket

• ZMTP over WebSocket?

• Connection inefficient

• Not extensible

• No easy parsers

Page 44: NullMQ @ PDX

WebSocket

Page 45: NullMQ @ PDX

WebSocket

• STOMP over WebSocket?

Page 46: NullMQ @ PDX

WebSocket

• STOMP over WebSocket?

• Existing parsers, easy to write

Page 47: NullMQ @ PDX

WebSocket

• STOMP over WebSocket?

• Existing parsers, easy to write

• Very much like HTTP

Page 48: NullMQ @ PDX

WebSocket

• STOMP over WebSocket?

• Existing parsers, easy to write

• Very much like HTTP

• Used primarily to multiplex

Page 49: NullMQ @ PDX

NullMQ

Page 50: NullMQ @ PDX

var url = "ws://hostname/gateway";var ctx = new nullmq.Context(url);socket = ctx.socket(nullmq.REP);socket.bind("nullmq://echo");socket.recvall(function(request) { socket.send("Got: "+request);});

Page 51: NullMQ @ PDX

var url = "ws://hostname/gateway";var ctx = new nullmq.Context(url);socket = ctx.socket(nullmq.REQ);socket.connect("nullmq://echo");socket.send("Hello world!");socket.recv(function(reply) { console.log(reply); // "Got: Hello world!"});

Page 52: NullMQ @ PDX

WebSocket

STOMP

NullMQ

Application

Browser

WebSocket

STOMP

NullMQ

Application

Server

Page 53: NullMQ @ PDX

WebSocket

STOMP

NullMQ

Application

Browser

WebSocket

STOMP

NullMQ

Bridge

Gateway Backend

ZMQ Socket

ZMQ Socket

ZMQ Socket

Page 54: NullMQ @ PDX

Presence Demo

Page 55: NullMQ @ PDX

NullMQ

http://github.com/progrium/nullmq

http://groups.google.com/group/nullmq

@progrium

@avalanche123

Page 56: NullMQ @ PDX
Page 57: NullMQ @ PDX

STOMP

Page 58: NullMQ @ PDX

STOMP• Simple and human-readable like HTTP

Page 59: NullMQ @ PDX

STOMP• Simple and human-readable like HTTP

• Extensible via headers

Page 60: NullMQ @ PDX

STOMP• Simple and human-readable like HTTP

• Extensible via headers

• Library and server support

Page 61: NullMQ @ PDX

STOMP• Simple and human-readable like HTTP

• Extensible via headers

• Library and server support

• An easy WebSocket subprotocol

Page 62: NullMQ @ PDX

STOMP• Simple and human-readable like HTTP

• Extensible via headers

• Library and server support

• An easy WebSocket subprotocol

• Can be used to model “virtual connections”

Page 63: NullMQ @ PDX

STOMP• Simple and human-readable like HTTP

• Extensible via headers

• Library and server support

• An easy WebSocket subprotocol

• Can be used to model “virtual connections”

• Transactions for multipart messages

Page 64: NullMQ @ PDX

STOMP “Extensions”

1. Frames include socket type header

2. Header for “connect” or “bind” in SUBSCRIBE

3. Req-Rep messages use “reply-to” header