REAL-TIME WEBMedhat DawoudNinja web developer at SCOPEwww.medhatdawoud.com
What is Real-time web• The meaning is that: users can see the contentsas fast as the author publish it (like chatapplicati...
To create Real-time system on web we need ..• Very fast web server.• Very very fast I/O operations (Non-blocking).• System...
Some technologies for Real-time systemsPython [ twisted ]Ruby [ EventMachine ]Perl [ AnyEvent ]If you deal with one of the...
Finally , The Magic Technology Appears• 2009 - this guy “Ryan Dahl” releases somethingthat support the highly-performancec...
What is Node.js ?• In simple words Node.js is ‘server-side JavaScript’.• In not-so-simple words Node.js is a high-performa...
What is Node.js ?• Built and run on V8 JavaScript engine.• In ‘Node.js’ , ‘.js’ doesn’t mean that its solely writtenJavaSc...
Google V8 engine• V8 is an open source JavaScript enginedeveloped by Google. It’s written in C++ and isused in Google Chro...
Theory 1 : Event-loopsEvent-loops are the core of event-driven programming, almostall the UI programs use event-loops to t...
Theory 2 : Non-blocking I/O• Traditional I/Ovar result = db.query(“select x from table_Y”);doSomethingWith(result); //wait...
Natural & Features of Node.js ( some confusing )• Apply it in the coolest, sexiest, most popularlanguage on the planet.• N...
Why JavaScript was suitable for that ?• JavaScript Callbacks feature that solve the problem ofevent-loops.• The great NPM ...
What can we do with Node.js• You can create an HTTP server and print ‘hello world’on the browser in just 4 lines of JavaSc...
Example: Creating Http server
When to use Node.js ?• streaming based Real-time services, onlinegames, web chat applications,..etc.• If you need high lev...
Some Benchmarks (proof of power)Taken from:http://code.google.com/p/node-js-vs-apache-php-benchmark/wiki/TestsA benchmark ...
Some Benchmarks (proof of power)Taken from:http://nodejs.org/jsconf2010.pdfThe benchmark shows theresponse time in milli-s...
Who is using Node.jsComplete list can be found at: https://github.com/joyent/node/wiki/Projects,-Applications,-and-Compani...
Some Modules you will love them• Express– to make things simpler e.g. syntax, DB connections.• Jade – HTML template system...
The last thing to say (How to start ?!)• Try to explore the rest of Node.js your self.• I recommend a free book to start c...
Medhat Dawoudwww.medhatdawoud .comTwitter: @Med7atdawoudThanks
Real time web
Real time web
Upcoming SlideShare
Loading in...5
×

Real time web

4,219

Published on

Simple Introduction to Real-time systems and specially using Node.js in that - at #CATscope13 SAT 27/4/2013

Published in: Technology
0 Comments
15 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
4,219
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
79
Comments
0
Likes
15
Embeds 0
No embeds

No notes for slide

Real time web

  1. 1. REAL-TIME WEBMedhat DawoudNinja web developer at SCOPEwww.medhatdawoud.com
  2. 2. What is Real-time web• The meaning is that: users can see the contentsas fast as the author publish it (like chatapplications)• A lot of technologies are used to implement theReal-time systems.• Today I’m interested in a technology that do thatfor us in an easy, reliable, and fantastic way
  3. 3. To create Real-time system on web we need ..• Very fast web server.• Very very fast I/O operations (Non-blocking).• System that depend on event-driven(event-loops).• Flexible tool to handle all of this in a simple way.
  4. 4. Some technologies for Real-time systemsPython [ twisted ]Ruby [ EventMachine ]Perl [ AnyEvent ]If you deal with one of them, this presentation will be really understood at once.
  5. 5. Finally , The Magic Technology Appears• 2009 - this guy “Ryan Dahl” releases somethingthat support the highly-performanceconcurrent applications.• It’s called Node.js
  6. 6. What is Node.js ?• In simple words Node.js is ‘server-side JavaScript’.• In not-so-simple words Node.js is a high-performancenetwork applications framework, well optimized for highconcurrent environments.• It’s Open Source. It runs well on Linux systems, canalso run on Windows systems.• uses an asynchronous event-driven model.
  7. 7. What is Node.js ?• Built and run on V8 JavaScript engine.• In ‘Node.js’ , ‘.js’ doesn’t mean that its solely writtenJavaScript. It is 40% JS and 60% C++.• is now the most followed project on Github,exceeding Ruby on Rails .. woooooo• From the official site:‘Nodes goal is to provide an easy way to build scalablenetwork programs’ - (from nodejs.org!)
  8. 8. Google V8 engine• V8 is an open source JavaScript enginedeveloped by Google. It’s written in C++ and isused in Google Chrome Browser.• Faster than SpiderMonkey (used in firefox) over4 times ( when V8 was invented ) - from an expert on stakoverflow -
  9. 9. Theory 1 : Event-loopsEvent-loops are the core of event-driven programming, almostall the UI programs use event-loops to track the user event, forexample: Clicks, Ajax Requests etc.ClientEvent loop(main thread)C++Threadpool(workerthreads)Clients send HTTP requeststo Node.js serverAn Event-loop is woken up by OS,passes request and response objectsto the thread-poolLong-running jobs runon worker threadsResponse is sentback to main threadvia callbackEvent loop returnsresult to client
  10. 10. Theory 2 : Non-blocking I/O• Traditional I/Ovar result = db.query(“select x from table_Y”);doSomethingWith(result); //wait for result!doSomethingWithOutResult(); //execution is blocked!• Non-traditional, Non-blocking I/Odb.query(“select x from table_Y”,function (result){doSomethingWith(result); //wait for result!});doSomethingWithOutResult(); //executes without any delay!
  11. 11. Natural & Features of Node.js ( some confusing )• Apply it in the coolest, sexiest, most popularlanguage on the planet.• Node.js uses an event-driven, non-blocking I/Omodel, which makes it lightweight.• The big support of V8 from Google is a great power.
  12. 12. Why JavaScript was suitable for that ?• JavaScript Callbacks feature that solve the problem ofevent-loops.• The great NPM (Node Package Manager).• Node.js JavaScript quite different : there is no DOMimplementation provided by Node.js,• i.e. you can not do this:var element = document.getElementById(“elementId”);• Everything inside Node.js runs in a single-thread.Natural & Features of Node.js ( some confusing )
  13. 13. What can we do with Node.js• You can create an HTTP server and print ‘hello world’on the browser in just 4 lines of JavaScript.• You can create a DNS server.• You can create a Web Chat Application like GTalk in thebrowser.• Node.js can also be used for creating online games,collaboration tools or anything which sends updates tothe user in Real-time.
  14. 14. Example: Creating Http server
  15. 15. When to use Node.js ?• streaming based Real-time services, onlinegames, web chat applications,..etc.• If you need high level concurrency and notworried about CPU-cycles.• If you are good at JavaScript code.• You will develop the front-end and back-end in the samelanguage, what a triumph 
  16. 16. Some Benchmarks (proof of power)Taken from:http://code.google.com/p/node-js-vs-apache-php-benchmark/wiki/TestsA benchmark between Apache+PHPand node.js, shows the response timefor 1000 concurrent connectionsmaking 10,000 requests each, for 5tests.
  17. 17. Some Benchmarks (proof of power)Taken from:http://nodejs.org/jsconf2010.pdfThe benchmark shows theresponse time in milli-secs for 4evented servers.
  18. 18. Who is using Node.jsComplete list can be found at: https://github.com/joyent/node/wiki/Projects,-Applications,-and-Companies-Using-Node
  19. 19. Some Modules you will love them• Express– to make things simpler e.g. syntax, DB connections.• Jade – HTML template system• Socket.IO– to create real-time apps• CoffeeScript – for easier JavaScript developmentFind out more about some widely used Node.js modules at:http://blog.nodejitsu.com/top-node-module-creators
  20. 20. The last thing to say (How to start ?!)• Try to explore the rest of Node.js your self.• I recommend a free book to start called• ( O’raily Book : Up and Running With Node.js)• Tutorial sites:• Nodejs.org• Letsnode.com• Google.com• The series of articles in arabic isA on ( medhatdawoud.com )
  21. 21. Medhat Dawoudwww.medhatdawoud .comTwitter: @Med7atdawoudThanks
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×