Real Time Realities!!!


Adding Real Time support to Your web app

         Kausikram Krishnasayee
          Silver Stripe Software
The History
The Steps
● Step 0 – get your code ready for real-time.
● Step 1 – lets start with some Websockets.

● Step 2 – lets show the same love to some old

browsers.
● Step 3 – Real-time strategies, to make life easy.

● Step 4 – Deployment, Scalability and Hair loss.
Code Is a Mess.
Truck factor is 1.
Business Logic, Data and Rendering
          are all tied up.
Testing is hard. Feature Addition is Harder...
There ARE going to be bugs....
Step 0




De Couple Logic, Data and Rendering
              (MVC)
Step 0




Lets look at the code again ...
Step 0


●   Code is much more cleaner
●   Code is easily testable
●   Change in logic, data schema and rendering
    is easy.
●   Adding new functionality is easy.
Step 1: websockets
Step 1



Bring in Real Time Support for browsers which
support the awesome HTML5 websocket spec.

 Write a fail safe for Browsers written for our
                   forefathers.
Step 1

    Note about Technologies used
●   Tornado running on a different port which
    basically echos back data to all concurrent
    connections
●   Using the native websocket JS api to make
    connections and update changes when there is
    a model change taking place.
●   Do nothing when on IE, if possible intimidate
    the user.
How to intimidate users nicely
Step 1




Lets look at the code again ...
Step 1

●   Real-time backend server running on a different
    port
●   Full real-time support for new browsers
●   No real-time support for old browsers
Step 1



If you hate IE users you can stop
              here....
Step 2 : Full Real-time support



Use a combination of comet, Web sockets, flash,
and any other possible technology that is possible
    to create a cross browser, almost similar
          functioning realtime system.
Step 2

             Note on technology

●   Comet: doing non HTTP things through HTTP
    ways...
●   Socket.io or js.io or something similar in the
    front end.
●   Socket.io / servers implementing connection
    negotiation mechanisms in the backend.
Step 2

●   Support for real Real-time even on IE 6.
●   Abstracted out API to perform real-time actions.
●   Peace of mind.
Step 3: pub sub systems
●   What if there are more than one task list?
●   How about activities performed through the
    API?
●   How about having a need to authenticate ?
Step 3

            Note on technology
●   Hookbox, Juggernaut or any other channel
    based pub-sub system
●   I wrote one myself :D
Step 3
Note on technology (Cont'd)
Backend to Live Server Connection.

Server                      Server




 LS                          LS
Step 4: Deploy, Scale and much
             more
Step 4

●   Running the LS on a different port is not a great
    idea.
●   How about handling a few hundred connections
    at the same time? What if you get Tech
    Crunched ?
●   What is the fall back option if LS crashes.
Thank You !!

Real Time Realitites

  • 1.
    Real Time Realities!!! AddingReal Time support to Your web app Kausikram Krishnasayee Silver Stripe Software
  • 2.
  • 3.
    The Steps ● Step0 – get your code ready for real-time. ● Step 1 – lets start with some Websockets. ● Step 2 – lets show the same love to some old browsers. ● Step 3 – Real-time strategies, to make life easy. ● Step 4 – Deployment, Scalability and Hair loss.
  • 4.
    Code Is aMess.
  • 5.
  • 6.
    Business Logic, Dataand Rendering are all tied up.
  • 7.
    Testing is hard.Feature Addition is Harder...
  • 8.
    There ARE goingto be bugs....
  • 9.
    Step 0 De CoupleLogic, Data and Rendering (MVC)
  • 10.
    Step 0 Lets lookat the code again ...
  • 11.
    Step 0 ● Code is much more cleaner ● Code is easily testable ● Change in logic, data schema and rendering is easy. ● Adding new functionality is easy.
  • 12.
  • 13.
    Step 1 Bring inReal Time Support for browsers which support the awesome HTML5 websocket spec. Write a fail safe for Browsers written for our forefathers.
  • 14.
    Step 1 Note about Technologies used ● Tornado running on a different port which basically echos back data to all concurrent connections ● Using the native websocket JS api to make connections and update changes when there is a model change taking place. ● Do nothing when on IE, if possible intimidate the user.
  • 15.
    How to intimidateusers nicely
  • 16.
    Step 1 Lets lookat the code again ...
  • 17.
    Step 1 ● Real-time backend server running on a different port ● Full real-time support for new browsers ● No real-time support for old browsers
  • 18.
    Step 1 If youhate IE users you can stop here....
  • 19.
    Step 2 :Full Real-time support Use a combination of comet, Web sockets, flash, and any other possible technology that is possible to create a cross browser, almost similar functioning realtime system.
  • 20.
    Step 2 Note on technology ● Comet: doing non HTTP things through HTTP ways... ● Socket.io or js.io or something similar in the front end. ● Socket.io / servers implementing connection negotiation mechanisms in the backend.
  • 21.
    Step 2 ● Support for real Real-time even on IE 6. ● Abstracted out API to perform real-time actions. ● Peace of mind.
  • 22.
    Step 3: pubsub systems ● What if there are more than one task list? ● How about activities performed through the API? ● How about having a need to authenticate ?
  • 23.
    Step 3 Note on technology ● Hookbox, Juggernaut or any other channel based pub-sub system ● I wrote one myself :D
  • 24.
    Step 3 Note ontechnology (Cont'd) Backend to Live Server Connection. Server Server LS LS
  • 25.
    Step 4: Deploy,Scale and much more
  • 26.
    Step 4 ● Running the LS on a different port is not a great idea. ● How about handling a few hundred connections at the same time? What if you get Tech Crunched ? ● What is the fall back option if LS crashes.
  • 27.