Realtime collaboration with
Clojure
EuroClojure - Barcelona, 2015
Leonardo Borges
@leonardo_borges
www.atlassian.com
www.leonardoborges.com
About
‣ Clojure engineer at Atlassian
‣ Functional Programming Advocate
‣ Founder of the Sydney Clojure User
Group
About
‣ Clojure engineer at Atlassian
‣ Functional Programming Advocate
‣ Founder of the Sydney Clojure User
Group
‣ Author of “Clojure Reactive Programming”
Stateless web servers are
user
user
user
user
user
web
server
state
user
user
user
user
user
web
server
state
user
user user
user
web
server
web
server
load balancer
user
user
user
user
user
DB
user
user user
user
web server
load balancer
state web server state web server state
Realtime collaboration
Realtime collaboration
Realtime collaboration
Operational Transformation 101
ello BBarcelona!
user server
ello BBarcelona!
Operational Transformation 101
ello BBarcelona!
user server
ello BBarcelona!
(ins 0 “H”)
Hello BBarcelona!
Operational Transformation 101
ello BBarcelona!
user server
ello BBarcelona!
(ins 0 “H”) (del 6)
Hello BBarcelona! ello Barcelona!
Operational Transformation 101
ello BBarcelona!
user server
ello BBarcelona!
(ins 0 “H”) (del 6)
Hello BBarcelona! ello Barcelona!
Operational Transformation 101
ello BBarcelona!
user server
ello BBarcelona!
(ins 0 “H”) (del 6)
Hello BBarcelona! ello Barcelona!
HelloBBarcelona! Hello Barcelona!
Operational Transformation 101
ello BBarcelona!
user server
ello BBarcelona!
(ins 0 “H”) (del 6)
Hello BBarcelona! ello Barcelona!
(del 7)
Operational Transformation 101
ello BBarcelona!
user server
ello BBarcelona!
(ins 0 “H”) (del 6)
Hello BBarcelona! ello Barcelona!
(del 7)Hello Barcelona! Hello Barcelona!
user
user
user
user
user
DB
user
user user
user
web server
load balancer
state web server state web server state
Where do we send requests to?
Where do we send requests to?
How do web nodes talk to each other?
Where do we send requests to? How do web nodes talk to each other?
What happens when web nodes
come up and down?
Where do we send requests to? How do web nodes talk to each other?
What delivery guarantees
are needed?
What happens when web nodes
come up and down?
Where do we send requests to? How do web nodes talk to each other?
What delivery guarantees
are needed?
What happens when web nodes
come up and down?
What ordering guarantees
are needed?
Where do we send requests to? How do web nodes talk to each other?
What delivery guarantees
are needed?
What happens when web nodes
come up and down?
What ordering guarantees
are needed?
Vert.x
Vert.x
-SockJS
-Clustering
-Distributed Event Bus
Vert.x
-SockJS
-Clustering
-Distributed Event Bus
Vert.x
-SockJS
-Clustering
-Distributed Event Bus
Actors
Actors
-State
-Location Transparency
-“At least once” delivery semantics
-Ordering guarantees
Actors
-State
-Location Transparency
-“At least once” delivery semantics
-Ordering guarantees
Actors
-State
-Location Transparency
-“At least once” delivery and ordering guarantees
Akka and Pulsar
-Aka is awkward to use from Clojure
-Clustering (in Pulsar)
-JVM only
-Fairness
Akka and Pulsar
-Aka is awkward to use from Clojure
-Clustering (in Pulsar)
-JVM only
-Fairness
Akka and Pulsar
-Aka is awkward to use from Clojure
-Clustering (in Pulsar)
-JVM only
-Fairness
Akka and Pulsar
-Aka is awkward to use from Clojure
-Clustering (in Pulsar)
-JVM only
-Fairness
user
web server state entity
Fairness
user
useruser
web server stateentity entity
Fairness
user
user
user
user
Fairness
Options Summary
Delivery Ordering Fairness End-to-End
Vert.x
Akka / Pulsar
Distributed
core.async
(custom code)
Right, so what did we end up doing?
Multiplexer
Multiplexer
Multiplexer
Multiplexer
Multiplexer
endpoint
duplex
channel
Multiplexer
Multiplexer
endpoint
web server state
duplex
channel
duplex
channel
Multiplexer
Multiplexer
endpoint
endpoint
web server state
web server state
duplex
channel
duplex
channel
duplex
channel
duplex
channel
web server state
Multiplexer
Multiplexer
endpoint
endpoint
web server state
web server state
duplex
channel
duplex
channel
duplex
channel
duplex
channel
Multiplexer
user
load
balancer
web server
state
Multiplex
web server
state
Multiplex
web server
state
Multiplex
Multiplexer
user
load
balancer
web server
state
Multiplex
web server
state
Multiplex
web server
state
Multiplex
Multiplexer
user
load
balancer
web server
state
Multiplex
web server
state
Multiplex
web server
state
Multiplex
Multiplexer
user
load
balancer
web server
state
Multiplex
web server
state
Multiplex
web server
state
Multiplex
Multiplexer
user
load
balancer
web server
state
Multiplex
web server
state
Multiplex
web server
state
Multiplex
Multiplexer
user
load
balancer
web server
state
Multiplex
web server
state
Multiplex
Aleph cluster
-Client and Server network programming
-Built on Netty and therefore asynchronous
-Hazelcast for group membership
Aleph cluster
-Client and Server network programming
-Built on Netty (async #FTW)
-Hazelcast for group membership
Aleph cluster
-Client and Server network programming
-Built on Netty (async #FTW)
-Hazelcast for group membership
Aleph cluster + multiplexer
-Distributed, end-to-end core.async channels
-Message delivery and ordering guarantees
-Fault tolerance
-Fairness
-Backpressure
Aleph cluster + multiplexer
-Distributed, end-to-end core.async channels
-Message delivery and ordering guarantees
-Fault tolerance
-Fairness
-Backpressure
What’s next?
CRDTs
Production release
Open-source
Realtime data synchronisation as a service
What’s next?
CRDTs
Production release
Open-source
Realtime data synchronisation as a service
What’s next?
CRDTs
Production release
Open-source
Realtime data synchronisation as a service
What’s next?
CRDTs
Production release
Open-source
Realtime data synchronisation as a service
References
Akka
Pulsar
Vert.x
Aleph
Jupiter OT algorithm
Consistent Hashing Ring
CRDTs in Riak
akka.io
bit.ly/actors-pulsar
vertx.io/
aleph.io/
bit.ly/jupiterOT
bit.ly/HashingRing
bit.ly/CRDTRiak
Thanks!
Questions?
Leonardo Borges
@leonardo_borges
www.atlassian.com
www.leonardoborges.com

Realtime collaboration with Clojure - EuroClojure - Barcelona, 2015