SlideShare uma empresa Scribd logo
1 de 17
Baixar para ler offline
Realtime at Lore
                      Using Node.js and Socket.io




                      Dan Getelman — May 9, 2012




Tuesday, May 15, 12
Why am I here?

                      • CTO/Co-founder at Lore (formerly
                        Coursekit)

                      • We built a system where real-time
                        updates are global. It’s been happily
                        running in production for about a year.




Tuesday, May 15, 12
Outline

                      • What we have
                      • How we ended up there
                      • How it works
                      • Lessons learned
                      • Miscellaneous Thoughts

Tuesday, May 15, 12
What’s our stack?

                      • Rich front-end framework
                      • node.js + socket.io for real-time
                        communications

                      • Python API

Tuesday, May 15, 12
How did we end up
                             here?
                      • Build best experience possible
                      • Strong vision for what we wanted —
                        solving general case way less work
                        than tons of specifics

                      • Able to leverage infrastructure both for
                        speed gains and real-time updating



Tuesday, May 15, 12
How did we end up
                             here?

                      • Sat down last summer, built it
                      • Pleasantly surprised by ease of
                        socket.io + Redis




Tuesday, May 15, 12
Goals

                      • Build awesome experience for
                        teachers/students

                      • Performance
                      • Secure

Tuesday, May 15, 12
Data Model
                              Restrictions
                      • Permission Groups let us simplify
                        updates significantly

                      • Individual models being pushed to front-
                        end

                      • Originally, circular dependencies not
                        allowed



Tuesday, May 15, 12
Two Browser
                       Connections
                 API                 Push


                        HTTPS
                                 WebSocket
                                 / Fallback



Tuesday, May 15, 12
Beauty of Push
                              Server
                      • Fills two roles:
                       • Lets us bypass browser concurrent
                          requests limits

                       • Lets us push any changes relevant to
                          a user down the pipe

                      • Socket.io generally lets us do this
                        without worrying about browsers


Tuesday, May 15, 12
Redis — Wonderchild

                      • Used in three very different ways,
                        generally happy with all

                      • Message queue
                      • Cache
                      • Pubsub

Tuesday, May 15, 12
How It Fits Together

                      • Subscribe to models (message via
                        socket.io)

                      • On write, determine which models care
                        about the change / addition

                      • Publish to their channel in Redis

Tuesday, May 15, 12
Front-end
                              Touchpoints
                      • Receiving and dispatching messages
                        (chat, notifications, updates)

                      • Fetching models
                      • Batch calls to improve performance

Tuesday, May 15, 12
Running in
                              production
                      • Handling HTTPS
                      • Load balancing
                      • Monit
                      • Metrics

Tuesday, May 15, 12
HTTPS

                 https = require 'https'
                 privateKey = fs.readFileSync("key.key").toString()
                 certificate = fs.readFileSync("ssl.pem").toString()

                 ca1 = fs.readFileSync("blah.pem").toString()

                 https.createServer {key:privateKey,cert:certificate, ca:
                 [ca1]}




Tuesday, May 15, 12
Lessons Learned

                      • Log everything
                      • Measure everything
                      • Unstable standards are unstable
                      • socket.io can be a bit opaque if things
                        aren’t going well



Tuesday, May 15, 12
Thanks!


                      • Follow me on Twitter: @dget
                      • We’re hiring!


Tuesday, May 15, 12

Mais conteúdo relacionado

Semelhante a Dan node meetup_socket_talk

Introducing Immutant
Introducing Immutant Introducing Immutant
Introducing Immutant Jim Crossley
 
How MongoDB is Being Used in China - Case Studies
How MongoDB is Being Used in China - Case StudiesHow MongoDB is Being Used in China - Case Studies
How MongoDB is Being Used in China - Case StudiesMongoDB
 
static ABAP code analyzers
static ABAP code analyzersstatic ABAP code analyzers
static ABAP code analyzersMarkus Theilen
 
Cloud4all Architecture Overview
Cloud4all Architecture OverviewCloud4all Architecture Overview
Cloud4all Architecture Overviewicchp2012
 
MuraCon 2012 - Creating a Mura CMS plugin with FW/1
MuraCon 2012 - Creating a Mura CMS plugin with FW/1MuraCon 2012 - Creating a Mura CMS plugin with FW/1
MuraCon 2012 - Creating a Mura CMS plugin with FW/1jpanesar
 
Phingified ci and deployment strategies ipc 2012
Phingified ci and deployment strategies ipc 2012Phingified ci and deployment strategies ipc 2012
Phingified ci and deployment strategies ipc 2012TEQneers GmbH & Co. KG
 
Scaling a High Traffic Web Application: Our Journey from Java to PHP
Scaling a High Traffic Web Application: Our Journey from Java to PHPScaling a High Traffic Web Application: Our Journey from Java to PHP
Scaling a High Traffic Web Application: Our Journey from Java to PHP120bi
 
Scaling High Traffic Web Applications
Scaling High Traffic Web ApplicationsScaling High Traffic Web Applications
Scaling High Traffic Web ApplicationsAchievers Tech
 
node.js in action
node.js in actionnode.js in action
node.js in actionKaran Misra
 
Kubernetes Scaling SIG (K8Scale)
Kubernetes Scaling SIG (K8Scale)Kubernetes Scaling SIG (K8Scale)
Kubernetes Scaling SIG (K8Scale)KubeAcademy
 
K8scale update-kubecon2015
K8scale update-kubecon2015K8scale update-kubecon2015
K8scale update-kubecon2015Bob Wise
 
MetaZeta Clusters Overview
MetaZeta Clusters OverviewMetaZeta Clusters Overview
MetaZeta Clusters OverviewPaul Baclace
 
JBoss Architect Meetup - December 2013 - JBoss Fuse in Vodafone’s Global Inte...
JBoss Architect Meetup - December 2013 - JBoss Fuse in Vodafone’s Global Inte...JBoss Architect Meetup - December 2013 - JBoss Fuse in Vodafone’s Global Inte...
JBoss Architect Meetup - December 2013 - JBoss Fuse in Vodafone’s Global Inte...JBossArchitectForum
 
“Scaling with LeSS” by Kārlis Cinis from Tieto Latvia at Large Scale Agile fo...
“Scaling with LeSS” by Kārlis Cinis from Tieto Latvia at Large Scale Agile fo...“Scaling with LeSS” by Kārlis Cinis from Tieto Latvia at Large Scale Agile fo...
“Scaling with LeSS” by Kārlis Cinis from Tieto Latvia at Large Scale Agile fo...DevClub_lv
 
Getting out of the monolith hell
Getting out of the monolith hellGetting out of the monolith hell
Getting out of the monolith hellmimmozzo_
 
Front end performance improvements
Front end performance improvementsFront end performance improvements
Front end performance improvementsMatthew Farina
 
IBM and Node.js - Old Doge, New Tricks
IBM and Node.js - Old Doge, New TricksIBM and Node.js - Old Doge, New Tricks
IBM and Node.js - Old Doge, New TricksDejan Glozic
 

Semelhante a Dan node meetup_socket_talk (20)

Introducing Immutant
Introducing Immutant Introducing Immutant
Introducing Immutant
 
How MongoDB is Being Used in China - Case Studies
How MongoDB is Being Used in China - Case StudiesHow MongoDB is Being Used in China - Case Studies
How MongoDB is Being Used in China - Case Studies
 
Qcon talk
Qcon talkQcon talk
Qcon talk
 
static ABAP code analyzers
static ABAP code analyzersstatic ABAP code analyzers
static ABAP code analyzers
 
Cloud4all Architecture Overview
Cloud4all Architecture OverviewCloud4all Architecture Overview
Cloud4all Architecture Overview
 
MuraCon 2012 - Creating a Mura CMS plugin with FW/1
MuraCon 2012 - Creating a Mura CMS plugin with FW/1MuraCon 2012 - Creating a Mura CMS plugin with FW/1
MuraCon 2012 - Creating a Mura CMS plugin with FW/1
 
Phingified ci and deployment strategies ipc 2012
Phingified ci and deployment strategies ipc 2012Phingified ci and deployment strategies ipc 2012
Phingified ci and deployment strategies ipc 2012
 
Scaling a High Traffic Web Application: Our Journey from Java to PHP
Scaling a High Traffic Web Application: Our Journey from Java to PHPScaling a High Traffic Web Application: Our Journey from Java to PHP
Scaling a High Traffic Web Application: Our Journey from Java to PHP
 
Scaling High Traffic Web Applications
Scaling High Traffic Web ApplicationsScaling High Traffic Web Applications
Scaling High Traffic Web Applications
 
node.js in action
node.js in actionnode.js in action
node.js in action
 
Kubernetes Scaling SIG (K8Scale)
Kubernetes Scaling SIG (K8Scale)Kubernetes Scaling SIG (K8Scale)
Kubernetes Scaling SIG (K8Scale)
 
K8scale update-kubecon2015
K8scale update-kubecon2015K8scale update-kubecon2015
K8scale update-kubecon2015
 
Measure Everything
Measure EverythingMeasure Everything
Measure Everything
 
MetaZeta Clusters Overview
MetaZeta Clusters OverviewMetaZeta Clusters Overview
MetaZeta Clusters Overview
 
JBoss Architect Meetup - December 2013 - JBoss Fuse in Vodafone’s Global Inte...
JBoss Architect Meetup - December 2013 - JBoss Fuse in Vodafone’s Global Inte...JBoss Architect Meetup - December 2013 - JBoss Fuse in Vodafone’s Global Inte...
JBoss Architect Meetup - December 2013 - JBoss Fuse in Vodafone’s Global Inte...
 
Architecting for failure
Architecting for failureArchitecting for failure
Architecting for failure
 
“Scaling with LeSS” by Kārlis Cinis from Tieto Latvia at Large Scale Agile fo...
“Scaling with LeSS” by Kārlis Cinis from Tieto Latvia at Large Scale Agile fo...“Scaling with LeSS” by Kārlis Cinis from Tieto Latvia at Large Scale Agile fo...
“Scaling with LeSS” by Kārlis Cinis from Tieto Latvia at Large Scale Agile fo...
 
Getting out of the monolith hell
Getting out of the monolith hellGetting out of the monolith hell
Getting out of the monolith hell
 
Front end performance improvements
Front end performance improvementsFront end performance improvements
Front end performance improvements
 
IBM and Node.js - Old Doge, New Tricks
IBM and Node.js - Old Doge, New TricksIBM and Node.js - Old Doge, New Tricks
IBM and Node.js - Old Doge, New Tricks
 

Dan node meetup_socket_talk

  • 1. Realtime at Lore Using Node.js and Socket.io Dan Getelman — May 9, 2012 Tuesday, May 15, 12
  • 2. Why am I here? • CTO/Co-founder at Lore (formerly Coursekit) • We built a system where real-time updates are global. It’s been happily running in production for about a year. Tuesday, May 15, 12
  • 3. Outline • What we have • How we ended up there • How it works • Lessons learned • Miscellaneous Thoughts Tuesday, May 15, 12
  • 4. What’s our stack? • Rich front-end framework • node.js + socket.io for real-time communications • Python API Tuesday, May 15, 12
  • 5. How did we end up here? • Build best experience possible • Strong vision for what we wanted — solving general case way less work than tons of specifics • Able to leverage infrastructure both for speed gains and real-time updating Tuesday, May 15, 12
  • 6. How did we end up here? • Sat down last summer, built it • Pleasantly surprised by ease of socket.io + Redis Tuesday, May 15, 12
  • 7. Goals • Build awesome experience for teachers/students • Performance • Secure Tuesday, May 15, 12
  • 8. Data Model Restrictions • Permission Groups let us simplify updates significantly • Individual models being pushed to front- end • Originally, circular dependencies not allowed Tuesday, May 15, 12
  • 9. Two Browser Connections API Push HTTPS WebSocket / Fallback Tuesday, May 15, 12
  • 10. Beauty of Push Server • Fills two roles: • Lets us bypass browser concurrent requests limits • Lets us push any changes relevant to a user down the pipe • Socket.io generally lets us do this without worrying about browsers Tuesday, May 15, 12
  • 11. Redis — Wonderchild • Used in three very different ways, generally happy with all • Message queue • Cache • Pubsub Tuesday, May 15, 12
  • 12. How It Fits Together • Subscribe to models (message via socket.io) • On write, determine which models care about the change / addition • Publish to their channel in Redis Tuesday, May 15, 12
  • 13. Front-end Touchpoints • Receiving and dispatching messages (chat, notifications, updates) • Fetching models • Batch calls to improve performance Tuesday, May 15, 12
  • 14. Running in production • Handling HTTPS • Load balancing • Monit • Metrics Tuesday, May 15, 12
  • 15. HTTPS https = require 'https' privateKey = fs.readFileSync("key.key").toString() certificate = fs.readFileSync("ssl.pem").toString() ca1 = fs.readFileSync("blah.pem").toString() https.createServer {key:privateKey,cert:certificate, ca: [ca1]} Tuesday, May 15, 12
  • 16. Lessons Learned • Log everything • Measure everything • Unstable standards are unstable • socket.io can be a bit opaque if things aren’t going well Tuesday, May 15, 12
  • 17. Thanks! • Follow me on Twitter: @dget • We’re hiring! Tuesday, May 15, 12