What is Node.Js and its Basic Understanding (Growing Technology)

>> Friday, July 5, 2013

What is Node.Js ?

Node.Js is one of the most dynamic and vibrant technology designed for writing scalable web application using the Google's V8 Javascript engine. the concept is developed by the Ryan dahl, contributed this as an Open source project, now its being administered by Joyent, Inc.
Its provide the capability to write a web application with the using of Javascript languange. Yes, That's why its called  SSJS (Server side Javascript). Its is used their built in HTTP Server, don't need to any other third party server like Apache, Tomcat or NginX to run this Node.Js application. you just need to install it by their NPM (Node package manager) and its ready to writing their first script.

http://nodejs.org/

Why we use Node.Js ?

One reason is efficiency. Node is basically very good when you need to do several things at the same time. Its is based on Event Driven Architecture approach which follows the Asynchronous approach in very organized manner. The traditional threaded approach to asynchronous code is cumbersome and creates a non-trivial memory footprint for large numbers of clients (each client spawns a thread, the memory usage of which adds up).
To avoid this inefficiency, as well as the known difficulty of programming threaded applications, Node.js maintains an event loop which manages all asynchronous operations for you.
When a Node application needs to perform a blocking operation (I/O operations, heavy computation, etc) it sends an asynchronous task to the event loop, along with a callback function,and then continues to execute the rest of its program.

Node is based on the realization that a lot of computer code actually just sits idle and wait for I/O most of the time, like waiting for a file to be written to disk or for a MySQL query to return data. To accomplish that, more or less every single function in Node.js is non-blocking.
In a web application, your main response time cost is usually the sum of time it takes to execute all your database queries. With node, you can execute all your queries at once, reducing the response time to the duration it takes to execute the slowest query.

Node.Js vs AJAX

As i was exploring this concept , my mind is quick prompted for AJAX. it is also known as Asynchronous approach Right?

Similarity :
The only similarity between AJAX and Node.js is that they are both JavaScript.

Difference:
AJAX (short for Asynchronous Javascript and XML) is a Client-side technology, often used for updating the contents of a page without refreshing it.

Node.js is Server-Side JavaScript, used for developing server software. For example, you wouldn't want to develop a database system in client-side JS (since, well, anyone could access the database's credentials obviously), but such a task is possible with Node.js.
Node.js doesn't get executed in a browser,but by a server - it's uses are very comparable to Apache/PHP, Ruby on Rails, Django, and like others web technology we generally used


Node Architecture




Code Sample (From Wiki)
This is an implementation of a "hello world" HTTP server in Node.js:
var http = require("http");
function onRequest(request, response) {
  console.log("Request received.");
  response.writeHead(200, {"Content-Type": "text/plain"});
  response.write("Hello World");
  response.end();
}

http.createServer(onRequest).listen(8888);

console.log("Server has started.");

Node Vs Tradiotional approach

When Apache2 serves up the PHP/JSP page it leaves the PHP/JSP code execution to a specific child process. That child process can only handle one request at a time so if
there are more requests than that, the others have to wait.

Also going for Node is the fact that everything is in one single process on the server.
One process with one active request handling thread. So thre’s no inter process communication between different instances and the ‘mother’ process.
Also, per request, Node is much more memory efficient.

Top 5 things you need to know about Node.Js

1. End to End Javascript : Always coders do the coding with Javascript and server side both for to develope a web applications. It would be good if every thing is written in only one common langugae "Javascript", which enhance the resource utilization is a very efficient manner,
2. Scalability : Designing scalable application is challanging, millions of users grows day by day. Node.Js capable to simplify asynchronous programming is what makes Node.js such a powerful tool for developers. With Node.js, you can build complex applications that can scale to millions of client connections because the application handling client requests is passing off all of the time-intensive work of managing I/O and computation to the event loop.
3. Real time web and Performance :  The web is moving fast, Real time web application is around the corner. Technologies such as Web Sockets are poised to allow millions of concurrent users to
enjoy latency-free interaction with web applications. This kind of massive concurrency is what Node.js really excels at.
For the performance perspective, Node.js is good option to start for that. Top Five companies (Google, Mozilla, Apple, Microsoft and Opera) competing over the best JavaScript implementation. Node is underlying the Google's V8 Interpreter which has become instantly fast and getting better day by day.
4. Maximize Hardware Resource utilization : Memory is one of the most expensive resource when it comes to hosting or to setup your dedicated hosting server. The very low memory footprint of Node.js allows you to maximize your use of current infrastructure.
5. Active community : Ryan dahl is creator of Node.Js which is sponsored by the Joyent organization. At this point, its groiwing and attracted to some of the smartest developers in industry. Its opensource project in which many developers actively contributed their module to GitHub.

Challenges with Node.Js

There are challenges with Node, both technical and cultural. On the technical side, the core design idea in Node is to have one process with one thread makes it a bit of a challenge to scale up on a multi core server.
If it had 2 cores, PHP/Apache would have been able to use that, but for Node to do the same, you have to do some tricks. Need to explore more and will continue in next articles :)

Follows the beginner books http://www.nodebeginner.org

0 comments:

Post a Comment

About This Blog »

This blog contains lots of valuable information related to IT technology,news,events as well as gossips. It contains the information about Software, Hardware, EDP, Software Languages tutorial and tricks..etc.
You will also find great "How To" articles on search engine optimization, what's happening in the world of the Wireless industry, Web services, Internet security, Web hosting plus a whole range of topics in the IT world.

Tech zone....Express »

Sci/Tech - Latest News »

2010©Techzonal

Back to TOP