realtimeconf: message passing vs. data synchronization

16
An Interlude by Quentin Cheshire Proudly Representing West RTC Message Passing vs. Data Synchronization

Upload: anant-narayanan

Post on 05-Dec-2014

539 views

Category:

Technology


2 download

DESCRIPTION

Video: http://vimeo.com/77352415 This talk, presented at RealtimeConf '13, is an overview of the pros and cons of using a data synchronization approach over message passing to build modern, distributed web applications.

TRANSCRIPT

Page 1: RealtimeConf: Message Passing vs. Data Synchronization

An Interlude by Quentin CheshireProudly Representing West RTC

Message Passing

vs.

Data Synchronization

Page 2: RealtimeConf: Message Passing vs. Data Synchronization

whoami?

Page 3: RealtimeConf: Message Passing vs. Data Synchronization

What’s all this fuss about?

was all the rage...

...which evolved intoLong-polling

lovingly known as “Comet”

WebSockets

Lo and Behold!

Introducing...

Data Channels

Page 4: RealtimeConf: Message Passing vs. Data Synchronization

Why Bother?

Users don’t like waiting Are obsolete

The Realtime Web is Here!

Page 5: RealtimeConf: Message Passing vs. Data Synchronization

How will you use the force?

It’s just a messaging channel!

Page 6: RealtimeConf: Message Passing vs. Data Synchronization

Have you thought this through?Persistence Fault Tolerance Scaling

Consistency Security

Page 7: RealtimeConf: Message Passing vs. Data Synchronization

Message Passing is a Primitive

Are better tools in order?

“All problems in computer science can be solved by another level of indirection abstraction”

Page 8: RealtimeConf: Message Passing vs. Data Synchronization

Data Synchronization

Most apps observe and modify data

That data reflects state

Your API should be built around this!

Page 9: RealtimeConf: Message Passing vs. Data Synchronization

An Example: Chat

var channel = new MessageChannel();

channel.subscribe(function(msg) { receivedNewMessage(msg);});

function sendMsg(msg) { channel.send(msg);}

var dataStore = new DataStore();

dataStore.on("new_row", function(msg) { receivedNewMessage(msg);});

function sendMsg(msg) { dataStore.addRow(msg);}

Page 10: RealtimeConf: Message Passing vs. Data Synchronization

An Example: Chat

var dataStore = new DataStore().limit(10);

dataStore.on("new_row", function(msg) { receivedNewMessage(msg);});

function sendMsg(msg) { dataStore.addRow(msg);}

Archival

Page 11: RealtimeConf: Message Passing vs. Data Synchronization

An Example: Chat

var dataStore = new DataStore();

dataStore.on("new_row", function(msg) { receivedNewMessage(msg);});

function sendMsg(msg) { dataStore.addRow(msg);}

Fault Tolerance

Page 12: RealtimeConf: Message Passing vs. Data Synchronization

An Example: Chat

var dataStore = new DataStore();

dataStore.on("new_row", function(msg) { receivedNewMessage(msg);});

function sendMsg(msg) { dataStore.addRow(msg);}

Security

{ ".read": "msg.to == auth.id"}

Page 13: RealtimeConf: Message Passing vs. Data Synchronization

Conceptually Simple

There’s a lot of complexity in turning astream of messages into usable state

Why not just directly store state?

Page 14: RealtimeConf: Message Passing vs. Data Synchronization

More Efficient

You have the flexibility to combine operations New clients only care about the latest state

1 → 2 → 3 → 4 → 5

Page 15: RealtimeConf: Message Passing vs. Data Synchronization

Automatic Merge BehaviorConflicts will typically require several messages to resolve

With a data abstraction, it can be a core primitive

Page 16: RealtimeConf: Message Passing vs. Data Synchronization

Data Sync not Message PassingDon’t let the primitives dictate how your application code is structured.Build the abstractions you need (Or use one of the available ones!)

Store state - don’t pass messages(Except when that’s really what you want to do)

Thank you!

wwwgithubtwitteremail

kix.inanantn@[email protected]