Node.js is a platform built on chrome's JavaScript runtime. It is use to create highly scalable , efficient network applications. I found this powerful language to create servers or network applications .
Some shout's about Node.js
Its a server side JavaScript . isn't it sounds cool.
I found it really good and damm fast.
On very 1st day , i have learned i m sharing (from a video)
Its a server side . running on server (webserver )
Its an Event Driven Programming which is very quick.
Node doesnt sleep or idle time is not there doesnt halted while connecting .
Good way to design program .
Don't need to buffer all mysql response.
It allows server to take lesser time to complete requests.
It performs better under concurrency. handle many requests.
It can handle another request while pause in 1 request . not in closed or idle state.
It has only one thread to handle request and it doesnot generate multiple threads for multiple request.
More Facts about node .
(some points are highlighted for convenience )
Evented and Non-blocking I/O
What makes Node exciting?
Some shout's about Node.js
Its a server side JavaScript . isn't it sounds cool.
I found it really good and damm fast.
On very 1st day , i have learned i m sharing (from a video)
Its a server side . running on server (webserver )
Its an Event Driven Programming which is very quick.
Node doesnt sleep or idle time is not there doesnt halted while connecting .
Good way to design program .
Don't need to buffer all mysql response.
It allows server to take lesser time to complete requests.
It performs better under concurrency. handle many requests.
It can handle another request while pause in 1 request . not in closed or idle state.
It has only one thread to handle request and it doesnot generate multiple threads for multiple request.
More Facts about node .
(some points are highlighted for convenience )
How Node works
Node itself runs V8 JavaScript on server. Server-side JavaScript
may be a new concept to everyone who's worked exclusively with JavaScript on
the client, but the idea itself isn’t that far fetched — why not uses the same
programming language on the client that you use on the server?
What's the V8? The V8 JavaScript engine is the underlying
JavaScript engine that Google uses with their Chrome browser. Few people think
about what actually happens with JavaScript on the client. Well, a JavaScript
engine actually interprets the code and executes it. With V8, Google created an
ultra-fast interpreter written in C++, with another unique aspect: you can
download the engine and embed it in any application you wish.
It's not restricted to running in a browser. So, Node actually uses the V8 JavaScript engine written by Google and repurposes it for use on the server. Perfect! Why create a new language when there's a good solution already available.
It's not restricted to running in a browser. So, Node actually uses the V8 JavaScript engine written by Google and repurposes it for use on the server. Perfect! Why create a new language when there's a good solution already available.
Event-driven
programming
Many programmers have been taught to believe that
object-oriented programming is the perfect programming design and to use
nothing else. Node utilizes what's called an event-driven programming model.
The server-side is actually no different than the client-side.
True, there are no buttons getting pressed, and no text fields getting typed in,
but on a higher level, events are taking place. A connection is made —
event! Data is received through the connection — event! Data stops coming
through the connection — event!
Why is this type of setup ideal for Node? JavaScript is a great
language for event-driven programming, because it allows anonymous functions
and closures, and more importantly, the syntax is familiar to nearly everyone
who has ever coded. The callback functions that are called when an event occurs
can be written in the same spot where you capture the event. Easy to code, easy
to maintain. No complicated Object Oriented frameworks, no interfaces, no
potential for over-architecting anything. Just listen for an event, write a
callback function and everything is taken care of!
Evented and Non-blocking I/O
This makes certain functionality extremely difficult to support.
Examples include handling large file uploads, combining resources from multiple
backend web APIs (which themselves can take an unpredictable amount of time to respond)
or providing comet functionality by holding open the connection until a new
event becomes available.
Event driven programming takes advantage of the fact that network
servers spend most of their time waiting for I/O operations to complete.
Operations against in-memory data are incredibly fast, but anything that
involves talking to the filesystem or over a network inevitably involves
waiting around for a response.
With Twisted, EventMachine and Node, the solution lies in
specifying I/O operations in conjunction with callbacks. A single event loop
rapidly switches between a list of tasks, firing off I/O operations and then
moving on to service the next request. When the I/O returns, execution of that
particular request is picked up again.
As you've
seen so far, Node is extremely well-designed for situations where you are
expecting a high amount of traffic and the server-side logic and processing
required isn't necessarily large before responding to the client. Here are some
good examples of where Node would excel:
- A RESTful API
A web service that provides a RESTful
API takes in a few parameters, interprets them, pieces together a response, and
flushes a response (usually a relatively small amount of text) back to the user.
This is an ideal situation for Node, because it can be built to handle tens of thousands of connections. It also doesn't require a large amount of logic, and basically just looks up values from a database and pieces together a response. Since the response is a small amount of text, and the incoming request is a small amount of text, the traffic volume isn't high, and one machine can likely handle the API demands of even the busiest company's API.
This is an ideal situation for Node, because it can be built to handle tens of thousands of connections. It also doesn't require a large amount of logic, and basically just looks up values from a database and pieces together a response. Since the response is a small amount of text, and the incoming request is a small amount of text, the traffic volume isn't high, and one machine can likely handle the API demands of even the busiest company's API.
- Twitter queue
Think about a company like Twitter that
has to receive tweets and write them to a database. There are literally
thousands of tweets arriving every second, and the database can't possibly keep
up with the number of writes required during peak usage times. Node becomes an
important cog in the solution to this problem. As we've seen, Node can handle
tens of thousands of incoming tweets. It can then quickly/easily write them to
an in-memory Queuing mechanism (memcached for example), from which another
separate process can write them to the database. Node's role in this is to
quickly gather the tweet and pass this information off to another process responsible
for writing it. Imagine another design — a normal PHP server that tries to
handle writes to the DB itself — every tweet would cause a small delay as its
written to the DB since the DB call would be blocking. A machine with this
design may only be able to handle 2000 incoming tweets a second, due to the
database latency.
- Video game
statistics
If you've ever played a game like Call
of Duty online, some things stick out at you immediately when you look at the
game statistics, mainly that they must be tracking a TON of info about the game
in order to produce that level of statistics.
Then, factor in the millions of people playing the game at any point, and you realize there is a TON of information getting generated very quickly. Node is a good solution for this scenario, because it can capture the data getting generated from the games, do a minimal amount of consolidation on them, and then queue them up for writing to a database.
It would seem silly to devote an entire server to tracking how many bullets people are firing in games, which might be the useful limit if you used a server like Apache, but it would seem less silly if instead you could devote a single server to tracking almost all the statistics from a game, like you might be able to do with a server running Node.
Then, factor in the millions of people playing the game at any point, and you realize there is a TON of information getting generated very quickly. Node is a good solution for this scenario, because it can capture the data getting generated from the games, do a minimal amount of consolidation on them, and then queue them up for writing to a database.
It would seem silly to devote an entire server to tracking how many bullets people are firing in games, which might be the useful limit if you used a server like Apache, but it would seem less silly if instead you could devote a single server to tracking almost all the statistics from a game, like you might be able to do with a server running Node.
·
Agile
Web development.
Today
is world of fast web development. Agile web development is not a specific
process, action, or a daylong exercise. Agile is a mindset, an attitude with
which a project is undertaken.
It means
streamlining the project, taking away time-sucks, performing frequent sanity
checks, and making sure that you’re not spending excessive time on things that
don’t add value to the project.
It’s
about spending quality time on actions that add value to the website and make
it better, and taking away time and energy from parts of the process that cause
headaches.
Your
team will reach the same goals and milestones, but in half the time or less.
In
this article, I’ll show you how the agile project management method can be applied to
developing websites.
Node.js
open gate for agile web development. Its ultra-fast performance on server makes
it possible. You can actually develop web application or website very quick
because node.js is small fast and no need to write lengthy code and amend
server according to your application that is a nice thing happen to node.js
·
Applications
for mobile devices
As
we all know mobile or smart phone in our pockets are our good friends,
direction teller, and endless things you can do with your smart phones (ios,
android) Node.js support application web server which deliver speed and
reliability to your app. App is easily communicate with node.js sever and
node.js sever communicate with backend database at very high speed so every app
runs with node.js sever is fast, reliable, easy to use.
·
Cloud
Development
Since
node.js is for scalable and high performance web servers. Cloud just needs high
performance and scalability.
From
the smart-phones in our pockets to the data centres and clouds that are
delivering the applications that businesses depend on, the technology landscape
is changing faster than ever. Drawn from the very best hardware, software,
development tools, and cloud services are provided.
Microsoft
also adapted Node.js for its Azure cloud platform as it provides its sdk for
cloud applications development.
What makes Node exciting?
If systems like this already exist, what’s so exciting about Node?
Quite a few things:
§ JavaScript is extremely well suited to programming with
callbacks. Its anonymous function syntax and
closure support is perfect for defining inline callbacks, and client-side
development in general uses event-based programming as a matter of course: run
this function when the user clicks here / when the Ajax response returns / when
the page loads. JavaScript programmers already understand how to build software
in this way.
§
Node
represents a clean slate.
Twisted and EventMachine are hampered by the existence of a large number of
blocking libraries for their respective languages. Part of the difficulty in
learning those technologies
is understanding which Python or Ruby libraries you can use and which ones you
have to avoid. Node creator Ryan Dahl has a stated aim for Node to never
provide a blocking API—even file system access and DNS lookups are catered for
with non-blocking callback based APIs. This makes it much, much harder to screw
things up.
§
Node is fast. V8 is the fast and keeps getting faster. Node’s event
loop uses Marc Lehmann’s highly regarded libev and libeio libraries. Ryan Dahl is himself
something of a speed demon—he just replaced Node’s HTTP parser implementation
(already pretty speedy due to it’s Ragel / Mongrel heritage) with a hand-tuned C implementation with some impressive
characteristics.
§
Easy to get started. Node ships with all of its
dependencies, and compiles cleanly on Snow Leopard out of the box.
With both my JavaScript and server-side hats
on, Node just feels right. The APIs make sense, it fits a clear niche and
despite its youth (the project started in February) everything feels solid and
well constructed. The rapidly growing community is
further indication that Ryan is on to something great here.
Advantages
of NODE.JS
Lower
memory consumption
All the web servers out
there have to face the concurrency environment and handle work with many
clients at the same time.
To allow you do that, they run in multiple threads.
In this model its standard situation that one connection is handled within one server thread. If you combine it with fact that each thread allocates its own heap memory stack, you will easily get conclusion that threaded model is not really effective in memory usage.
To allow you do that, they run in multiple threads.
In this model its standard situation that one connection is handled within one server thread. If you combine it with fact that each thread allocates its own heap memory stack, you will easily get conclusion that threaded model is not really effective in memory usage.
Node has different
strategy for that. Event driven code based on the infinite event loop allows it
to work in totally different way – in one thread. This way Node avoid the need
to allocate large heap memory objects for each client. It keeps simple workflow:
1.
First think what you do is to register a listener function – callback. This way
you say which function will run the code in case event is fired.
2.
Server is waiting in infinite loop for an event within the event loop.
3.
Once the event is fired Node runs the callback code. Once callback is done with
its work, server get back to the event loop waiting for another one.
This way every action is
asynchronous and no operation blocks. From its principle Node can’t allow you
do that, because you are still working in one thread.
Better
usage of CPU power
Node takes care about
lowering usage of CPU too. In traditional thread model, server has to spawn
threads and switch the context constantly between them. These operations are
expensive and causing CPU usage overhead along with the possibility of
dead-lock and another thread programming problems causing many developers lot of
gray hairs.
Node avoids this problems
running rather in single thread using the event loop and callbacks. If you
think its not much effective to use just one core of your CPU, nothing stops
you from running multiple separate Node instances and load balance them with
proxy like Nginx.
Node.js uses event-driven,
asynchronous I/O that minimizes overhead and maximizes scalability. This makes
Node.js an ideal platform for data intensive real-time (DIRTy) applications
that include:
Applications for mobile
devices
Cloud development
The Internet of Things
Online gaming applications
Embedded,
industry-specific devices and applications
Location-based
advertising, incentive programs and services
Other
Advantages.
- Performance. It's fast. Real fast.
- One big advantage of node.js is the low level API. You have a lot of control. And it’s Open source.
- You have the entire HTTP server integrated directly into your code then outsourced to IIS.
- The entire C10K challenge is handled well by node but not by IIS
- Ajax and Json communication feels natural and easy.
- Real time communication is one of the great things about node.js. It was made for it.
- Plays nicely with document based NOSQL databases. Like mongodb and couchdb.
- Can run a TCP server as well. Can do file writing access can run any Unix console command on the server.
- You query your database in JavaScript using for example couch db and map/reduce. You write your client in JavaScript. There are no context switches whilst developing on your web stack.
- Rich set of community driven open source modules. Everything in node.js is open source.
No comments:
Post a Comment