Node.js

  • 1,236 views
Uploaded on

An overview of how Node.JS works

An overview of how Node.JS works

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
1,236
On Slideshare
0
From Embeds
0
Number of Embeds
2

Actions

Shares
Downloads
5
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 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.  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.  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. Wait for Connection
  • 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. “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.  (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.  “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. 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.  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.  Browserling.com Doodleordie.com Ge.tt Kodingen.com Multiplayerchess.com Orona Wordsquared.com Musicquiz.to