• Save
Nodejs
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

Nodejs

on

  • 1,774 views

 

Statistics

Views

Total Views
1,774
Views on SlideShare
1,771
Embed Views
3

Actions

Likes
3
Downloads
2
Comments
0

2 Embeds 3

http://www.linkedin.com 2
http://duckduckgo.com 1

Accessibility

Categories

Upload Details

Uploaded via as OpenOffice

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Nodejs Presentation Transcript

  • 1. node.js
  • 2. Concurrency?
  • 3. In system level it is achieved by Time Division Multiplexing
  • 4. 1. Process Forking
  • 5.  
  • 6. Process Forking
  • 7.
      2. Threads
  • 8.  
  • 9.
      Threads?
  • 10. a. Context switching between threads is faster than that between processes
  • 11. a. Context switching between threads is faster than that between processes a. Context switching between threads is not free
  • 12. b. Multiple threads within a process share state as well as memory and other resources
  • 13. b. Multiple threads within a process share state as well as memory and other resources b. Call stack associated with a thread is > 0 bytes
  • 14.  
  • 15. c. Scaling is achieved by creating a new thread per connection.
  • 16. c. Scaling is achieved by creating a new thread per connection. c. For massive concurrency we can not use one O/S thread per connection.
  • 17.  
  • 18. d. Creating a thread is faster than creating a process.
  • 19. d. Creating a thread is faster than creating a process. d. Thread creation is not really cheap, and in some systems it's costlier than forking.
  • 20.  
  • 21. Threaded model drops in performance as concurrency increases
  • 22. 1. Using Java NIO/MQ for asynchronous calls, I/O operations. 2. Using green threads 3. Thread pooling
  • 23. But it needs expert knowledge and system level hacking in some cases.
  • 24. Concurrency?
  • 25. 3. Event Loop
  • 26.  
  • 27. a. Long running routines will block the loop
  • 28. Event loop can not support long running blocking routines
  • 29. What is long running?
  • 30. I/O
  • 31. I/O latency eats CPU cycles
  • 32. Non blocking, asynchronous I/O
  • 33. node.js
  • 34. Provides a simplistic API to write extremely scalable event-driven server
  • 35.
    • Server side js
    • 36. Evented non/blocking i/o
    • 37. Built on V8 Engine
    • 38. CommonJS standard
  • 39. Evented non blocking platform to write high concurrent applications
  • 40. How it works?
  • 41. How Browser Works
    • Event Loop
    • 42. Non blocking I/O
    • 43. Interrupts
  • 44. How to use it?
  • 45. // Old blocking style resultSet = database.select("something"); // wait... tap tap tap doStuff(resultSet);
  • 46. // New non-blocking style database.select("something", function(resultSet) { // called on completion doStuff(resultSet); });
  • 47. var sys = require('sys'), http = require('http'); http.createServer(function (req, res) { setTimeout(function () { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello World! '); }, 2000); }).listen(8000); sys.puts('Server running at http://127.0.0.1:8000/'); Hello World!
  • 48. Where can we use it?
  • 49.
    • commet apps
    • 50. real time application
    • 51. socket apps
    • 52. ...
  • 53. Good stuffs
    • Single configuration, multiple instances
    • 54. Loads of available modules
    • 55. It's JS, easy to install and deploy
  • 56. Bad stuffs
    • Can not scale to multiprocessor architecture yet
  • 57. var sys = require("sys"); sys.puts("Happy Hacking!");