Real-Time Push Notifications
Chats
Games
Remote Procedure Calls (RPC)
Message loss
Scaling/failover issues
Software upgrade issues
Custom routing
A modern HTTP edge server
with smart websocket support
A (reverse) proxy
Serves files (just in case)
Websockets
Routing
Replication
Data Model
Software Updates (*)
RPC
Pub-Sub
Lattice
user1 → ☂: call chat.send_message(x)
☂ → backend1: chat.send_message("user1", x)
backend1 → ☂: return "ok"
☂ → user1: return "ok"
chat.* → chat{1,2,3}
pizza.* → pizza{1,2}
Prefix Routing
Sticky Auth
user1 → backend: I want room "kittens"
backend → ☂: subscribe(user1, @rooms.kittens)
user1 → backend: Send "hello"
backend → ☂: send(@rooms.kittens, "user1: hello")
WAMP: subscription from client
Swindon ☂: subscription from backend
(*) Web Application Messaging Protocol
Authorization
First time sync
Room List
Unread Messages
Chat History
Multiple tabs/devices
Eventual consistentcy
Lost/duplicate messages
user1 -> messages read
user2 -> new message
user1 -> -1 unread
user2 -> +1 message
device1 -> get_rooms
device2 -> add_room
device1 -> get_rooms
user2 -> new mesage
device2 -> add_room
user3 -> new mesage
Commutative Replicated Data Types
Solves eventual consistency problem
Counter/Max
Game: Experience
Chat: Last Message Id
Metadata Version
Two ever growing counters:
Earned Money
Spent Money
Total Messages
Last Read No.
Auto-updates room list
Conflict-free eventual consistency
swindon-dev ./public /api/=http://localhost:8111
cargo install swindon