What we Learn?
points
Monica Deshmane(H.V.Desai College, Pune)
2.1 Introduction
2.2 What is Node ?
2.3 Traditional Web Server Model
2.4 Node JS Process model
Introduction
Why node js?
Node.js uses asynchronous programming!
Ex. a web server opens a file on the server and return
the content to the client.
Here is how PHP or ASP handles a file request:
1. Sends the task to the computer's file system.
2. Waits till the file system opens and reads the file.
3. Returns the content to the client.
Ready to handle the next request.
Why node js?
Monica Deshmane(H.V.Desai College, Pune)
Introduction
Here is how Node.js handles a file request:
1. Sends request to the computer's file system.
2. Ready to handle the next request.
3. When the file system has opened and read the file,
4. the server returns the content to the browser.
Node.js minimizes the waiting, and simply continues with
the next request.
Node.js runs single-threaded, non-blocking,non-waiting
asynchronously programming, which is very memory
efficient.
Why node js?
Monica Deshmane(H.V.Desai College, Pune)
Basics of Node JS
What is node js?
Node.js is an open source ,
cross-platform runtime environment
for developing server-side applications
and networking applications
Node.js is free
Node.js runs on various platforms
(Windows, Linux, Unix, Mac OS X, etc.)
Node.js uses JavaScript on the server
Node.js was developed by Ryan Dahl in 2009 and its
latest version is v0.10.36(now it may vary)
What is
node js?
Monica Deshmane(H.V.Desai College, Pune)
Basics of Node JS
What Can Node.js Do?
Node.js can generate dynamically page contents
Node.js can create, open, read, write, delete, and close files
i.e perform operations with files on the server
Node.js can perform operations on data like, add, delete, modify
and collect data from your database
What is a Node.js File?
Node.js files contain tasks that will be executed on certain events.
An event is for trying to access a port on the server
Node.js files must be initiated on the server before having any
effect
Node.js files have extension ".js"
What
node js does?
Monica Deshmane(H.V.Desai College, Pune)
Features of Node.js
1. Asynchronous and Event Driven −
All APIs of Node.js library are asynchronous,
means, Node.js server not waits for an API to
return data.
The server moves to the next API after calling it and a
notification mechanism of Events of Node.js helps
the server to get a response from the previous API
call.
2.Very Fast −
It built on Google Chrome'sV8 JavaScript Engine, so
Node.js library is very fast for code execution.
7
Features of Node.js(continue..)
3. SingleThreaded but Highly Scalable −
Node.js uses a single threaded model with
event looping.
Node.js uses a single threaded program and
the same program can provide service to a
number of requests than traditional servers
like Apache Server.
4. No Buffering −
Node.js applications never buffer any data.
But output the data in chunks.
5. Node.js is released under the MIT license
8
(Revise)Features of Node.js
Asynchronous and Event Driven
Very Fast
SingleThreaded but Highly Scalable
No Buffering
License
9
Advantages of Node JS
1. Node.js offers an Easy Scalability
it easy to scale the applications
in horizontal by adding nodes in system and
in vertical by adding extra resources to the single nodes .
2. Easy to Learn And light weight framework
3. Node.js is used as a Single Programming Language
allows the Node.js developers to write both the front-end
as well as the back-end web application in JavaScript using a
runtime environment.
4. The Benefit of Fullstack JS
It saves both money and time.
5. Known for Offering High Performance
The speed of the code execution increased by runtime environment
as it supports the non-blocking I/O operations.
6 . The Support of Large and Active Community
Advantages
Monica Deshmane(H.V.Desai College, Pune)
The Drawbacks of Node.js
Drawbacks
1. Application Programming Interface (API) is Not Stable
2. not having a Strong Library Support System
3. Asynchronous Programming Model
Applications of node js
1.Game developments
2.Designing servers
3.Collaborative work
4.Chatting applications
Node JS Process model
asynchronous
web server model
using Node.js.
Monica Deshmane(H.V.Desai College, Pune)
Node JS Process model
•Node.js processes user requests differently when
compared to a traditional web server model.
• Node.js runs in a single process and the application code
runs in a single thread and so needs less resources.
All the user requests to your web application handled by a
single thread and all the I/O work or long running job.
So, this single thread doesn't have to wait for the request to
complete and is free to handle simultaneousely the next
request.
If there is no blocking process, node will prepare the
response immediately and send it back to client.
continue....
Monica Deshmane(H.V.Desai College, Pune)