Thinking asynchronously: events on the realtime web

27
Thinking asynchronously Sherwood McGraw des. rep. Peer Anarchy, es262 librarians’ syndic, zone TC39

description

My presentation (speaking as Sherwood McGraw) at the most recent, best, and final RealtimeConf. To really understand the implications of asynchronous distributed systems, it's helpful to think about things from the point of view of the data, and to get as explicit as possible about how your data models and flows bind time and space together.

Transcript of Thinking asynchronously: events on the realtime web

Page 1: Thinking asynchronously: events on the realtime web

Thinking asynchronouslySherwood McGraw

des. rep. Peer Anarchy, es262 librarians’ syndic, zone TC39

Page 2: Thinking asynchronously: events on the realtime web

HARD REALTIME

> system-centric

> cybernetics & control systems

> trading & arbitrage

> fixed time budgets

Page 3: Thinking asynchronously: events on the realtime web

SOFT REALTIME

> person-centric

> chat, commerce & social media

> games

> must be “fast”

Page 4: Thinking asynchronously: events on the realtime web

REALTIME

CONCURRENCY ASYNCHRONY DISTRIBUTION

Page 5: Thinking asynchronously: events on the realtime web

CONCURRENCY ASYNCHRONY DISTRIBUTION

Page 6: Thinking asynchronously: events on the realtime web

CONCURRENCY

ASYNCHRONY

DISTRIBUTION

Page 7: Thinking asynchronously: events on the realtime web

ASYNCHRONY

Page 8: Thinking asynchronously: events on the realtime web

ASYNCHRONYtime space

Page 9: Thinking asynchronously: events on the realtime web
Page 10: Thinking asynchronously: events on the realtime web

VERTICAL

> lockstep> control flow is imposed> independent> PUSH

Page 11: Thinking asynchronously: events on the realtime web

HORIZONTAL

> fire and forget> control flow is emergent> interdependent> PULL

Page 12: Thinking asynchronously: events on the realtime web

> browsers & mobile are increasingly peers rather than clients

> the horizontal model maps well to peer-to-peer architectures

> the network becomes an event bus connecting agents, rather than a pipe pushing data

p2p

Page 13: Thinking asynchronously: events on the realtime web

but

Page 14: Thinking asynchronously: events on the realtime web

HORIZONTAL

Page 15: Thinking asynchronously: events on the realtime web
Page 16: Thinking asynchronously: events on the realtime web
Page 17: Thinking asynchronously: events on the realtime web
Page 18: Thinking asynchronously: events on the realtime web

“this happened and then this happened and then this happened and then this happened”

synchronous story

Page 19: Thinking asynchronously: events on the realtime web

asynchronous story

“This happened. That happened. This other thing happened. You tell me what it all means.”

Page 20: Thinking asynchronously: events on the realtime web

> self-contained (or isolated)

> each piece self-contained

> or only knows what’s next

asynchronous data

Page 21: Thinking asynchronously: events on the realtime web

the difference

> in one, the structure of computation determines the sequence of events

> in the other, that structure is relaxed or absent, and the underlying structure is simpler

Page 22: Thinking asynchronously: events on the realtime web

example: promises

> promises abstract over not just time but space

> each step processes 1 thing & returns 1 thing

> can be composed, which reintroduces dependencies

> most frequently a simple pipeline

Page 23: Thinking asynchronously: events on the realtime web

async ⊃ sync

> async is more general than sync

> async data have fewer dependencies

> sync data fits in an async frame, but not vice versa

Page 24: Thinking asynchronously: events on the realtime web

> callbacks & observables are simple and composable

> callbacks & observables are confusing and hard to reason about

simpler != easier

Page 25: Thinking asynchronously: events on the realtime web

so

> the results can be simpler, more efficient distributed systems

> but, designers & developers of async systems have more work to do

> and to use it effectively you must change your frame of reference

Page 26: Thinking asynchronously: events on the realtime web

how

> basic principles of software engineering:

> loose coupling

> stratification

> smallest useful units of modularity

Page 27: Thinking asynchronously: events on the realtime web

why

> smaller, more composable designs

> does less computation because you’ve done more work up front

> matching the native model of the realtime web