yodlr realtime technology stack
TRANSCRIPT
@RossKukulinski
WebRTC, Node.JS, and Socket.io in Production
Silicon Valley Realtime October 7, 2015
@RossKukulinski
Ross Kukulinski Yodlr Founder / CEO
BayNode Organizer
nodejs Evangelist
Soccer Fanatic
@RossKukulinski
Yodlr: Easy Virtual Presentations• Runs in your web browser
• No plugins or downloads
• HD voice chat
• Audio recording
• File sharing
• PDF/Powerpoint presentations
• Support for large meetings & webinars
@RossKukulinski
@RossKukulinski
Our Tech StackInfrastructure Database Server-Side Client-Side
@RossKukulinski
Our Client-Side• WebRTC
• Access to microphone & speaker via browser
• Streams audio over network to our mixing service
• Socket.io
• Realtime connection to presence/chat/upload services
• We only enable websocket protocol
@RossKukulinski
Scaling WebRTC Media
Image credit: Philipp Hancke
@RossKukulinski
Scaling WebRTC Media
Image credit: Philipp Hancke
@RossKukulinski
Scaling WebRTC Media
Image credit: Philipp Hancke
@RossKukulinski
Scaling WebRTC Media
Media Server(s)
@RossKukulinski
Socket.io & NodeJS• Socket.io
• “Real-time bidirectional event-based communication”
• Built on top of websockets (can fall back to long-polling)
• NodeJS
• Excellent at maintaining many concurrent connections
• But… Node is single threaded
• Scale by running multiple instances of your application
@RossKukulinski
Socket.io in Production• Enable sticky load balancing if using XHR Polling or JSONP Polling
• Need a database layer if:
• Broadcast messages between clients
• Using built-in ‘rooms’ feature
• Authentication
• Authentication?
• JSON Web Token (JWT)
• Custom middleware functions
@RossKukulinski
Socket.io Database• Defaults to a memory-store
• Redis is the ‘popular’ database store
• Note: messages are NOT persistent
• Other DB support by extending socket.io-adapter
• socket.io-rethinkdb
• socket.io-mongo last updated 2 years ago :(
@RossKukulinski
Redis• Simple key/value store with pub-sub
• Easy to setup and build with
• FAST!
• But… HA is a pain in the neck
• Not really geared toward persistent/long-term storage
@RossKukulinski
Our Database Layer• Long-term Storage: Mongodb
• User accounts / Credentials / Permissions
• Historical anonymized usage data
• Temporary Storage: Redis
• Realtime room data
• Socket.io persistence layer
@RossKukulinski
Here’s a crazy idea
@RossKukulinski
Database with persistent storage AND pub-sub
capability
@RossKukulinski
@RossKukulinski
Our New Tech Stack?Infrastructure Database Server-side Client-Side
@RossKukulinski
DBaaS or self-hosted
• Mongodb hosted by ObjectRocket (Rackspace)
• Redis self-hosted
• In general: If you don’t have a DBA, go with a DBaaS
@RossKukulinski
In an alternate universe…
• Ditch socket.io for SaaS pub/sub/message system
• e.g. PubNub, Firebase, Pusher
• Might be lower TCO, but vendor lock-in concern
@RossKukulinski
Realtime DevOps
• Measure everything
• Statsd / Graphite / Grafana
• Deploy early & often (CI/CD)
• We LOVE Docker, Kubernetes, & CoreOS