Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does Node.js work from a network / TCP / HTTP connection perspective? Can WCF emulate this?

My understanding is that node.js is a python app that is geared towards the Linux world. Everyone seems to be quite happy with it's speed and ability to handle many concurrent connections.

I'm coming from a Microsoft background and think node.js might be able to be implemented using WCF.

Can someone tell me how node.js operates from a network background, and optionally provide insight if this can be ported to WCF or the Azure Service Bus?

like image 563
makerofthings7 Avatar asked Mar 13 '11 19:03

makerofthings7


2 Answers

Node is a Javascript framework that favors requires an event-driven approach to writing network services. Instead of blocking on networking operations, which is how network programming is usually done, Node gives you event handlers that are triggered when interesting stuff happens (clients connect, bytes arrive, DNS queries return, &c.).

As a consequence, Node is well-suited to and is being widely explored for realtime web apps. A host of interesting libraries for Node are now available, thanks to it being a Javascript framework. Some of them hide incredible power behind a very cute API.

There are binary versions of Node for Windows, but they are not deemed stable yet. Node is much lower level than WCF/Azure -- it's an event driven wrapper for sockets, DNS, HTTP, &c. if you will. It does not enforce any requirements as to how a networked service should be implemented (such as contracts or data marshalling) other than being event driven. I believe implementing a Node clone on top of those technologies would harm low-latency (at least), but perhaps someone more qualified can tell if it can be done.

PS. The Node website does a good job of explaining how it all works.

PPS. Possibly related, although I didn't have the time to read a lot about it, is Rx for .NET.

like image 175
andref Avatar answered Oct 17 '22 18:10

andref


Node.js is a (really nice) programming model that's leveraging the great suitability of Javascript for asynchronous programming for implementing asynchronous web apps. The principle is very similar to the asynchronous programming model on Windows and especially in .NET (WCF supports this quite well) where all work is done on callbacks invoked by I/O threads and the app never locks a thread. Node.js creates a stringent JS programming model around this foundational mechanism to allow better scaling apps. So contrary to what a few folks here are saying, Node.js is quite exactly at the same layer/level as WCF. From a protocol perspective a Node.js implementation will likely always sit between the app and the HTTP listener provided by the underlying HTTP infra.

like image 42
Clemens Vasters Avatar answered Oct 17 '22 19:10

Clemens Vasters