   Interpreted using Google’s V8 JavaScript    engine (same one they use in Chrome)   Provides some core libraries (netw...
   It’s not browser / document JavaScript   It’s not jQuery   It’s not PHP/Ruby/ASP.NET/other server-side    language ...
   Functions are Objects    ◦ Passed as arguments into other functions    ◦ Similar to Lambdas / Anonymous Methods in .NE...
Wait for Connection
   Waiting for expensive operations is stupid   Single thread event loop    ◦ Your code is single-threaded, so you don’t...
“Everything runs in parallel, except your code”           Go read this file           Go listen for this message          ...
   (Almost) All interaction is done via events and    callbacks   If your code relies on multiple async    operations to...
   “parallel” IO execution allows you to make    expensive queries at the same time,    increasing efficiency   One lang...
100,000 requests1,000 concurrent                  Node        Apache /                              PHPFailed Requests    ...
   Uses more CPU and RAM on server (only a    little more, but more nonetheless)   Can get complicated if doing more tha...
   Browserling.com   Doodleordie.com   Ge.tt   Kodingen.com   Multiplayerchess.com   Orona   Wordsquared.com   Mus...
Node.js
Node.js
Node.js
Upcoming SlideShare
Loading in …5
×

Node.js

1,664 views

Published on

An overview of how Node.JS works

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

  • Be the first to like this

No Downloads
Views
Total views
1,664
On SlideShare
0
From Embeds
0
Number of Embeds
306
Actions
Shares
0
Downloads
7
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Node.js

  1. 1.  Interpreted using Google’s V8 JavaScript engine (same one they use in Chrome) Provides some core libraries (network, IO, console, etc.) Supports extensions / modules Is both a runtime environment and a library
  2. 2.  It’s not browser / document JavaScript It’s not jQuery It’s not PHP/Ruby/ASP.NET/other server-side language It’s not Apache / IIS
  3. 3.  Functions are Objects ◦ Passed as arguments into other functions ◦ Similar to Lambdas / Anonymous Methods in .NET ◦ Ajax.oncomplete = function(result) { document.write(result); }; ◦ $.ajax(function(result) { document.write(result); }); Callbacks EVERYWHERE
  4. 4. Wait for Connection
  5. 5.  Waiting for expensive operations is stupid Single thread event loop ◦ Your code is single-threaded, so you don’t have to deal with any concurrency / shared state / other multi-threaded problems ◦ Expensive “back-end” operations are spawned as separate processes and trigger events and/or call back to your code when they’re finished
  6. 6. “Everything runs in parallel, except your code” Go read this file Go listen for this message Go download this image K, I’m done Waiting
  7. 7.  (Almost) All interaction is done via events and callbacks If your code relies on multiple async operations to complete, you’ll have to do a bit of call management / abstraction All of “your code” should return very quickly, or create itself as an async object (via EventEmitter)
  8. 8.  “parallel” IO execution allows you to make expensive queries at the same time, increasing efficiency One language to rule them all – server side and client side code for the same web app V8 is one of the fastest script interpreters on the planet Ridiculously fast benchmarks ◦ 600% faster than apache
  9. 9. 100,000 requests1,000 concurrent Node Apache / PHPFailed Requests 147 879Requests/seco 4725.4 823.38nd 3Total 211.62 1214.51ms/request 1 0Processing time 40 565(ms)/requestTotal time (s) 21.162 121.451
  10. 10.  Uses more CPU and RAM on server (only a little more, but more nonetheless) Can get complicated if doing more than one async call per request Lots of node-specific language constructs ◦ require, exports, etc. Uses JavaScript, which in itself has a lot of quirks and fallacies
  11. 11.  Browserling.com Doodleordie.com Ge.tt Kodingen.com Multiplayerchess.com Orona Wordsquared.com Musicquiz.to

×