0% found this document useful (0 votes)
32 views

The Server-Side Javascript: Veera

This document provides an overview of Node.js, describing it as an open source server environment that uses JavaScript and runs on various platforms, highlighting how Node.js is asynchronous and single-threaded which allows it to handle a large number of concurrent connections more efficiently than traditional Apache servers. Key aspects covered include the Node.js architecture, event loop, blocking vs non-blocking I/O, performance benchmarks, and instructions for downloading, installing, and creating a simple example Node.js program.

Uploaded by

bhadri1255
Copyright
© © All Rights Reserved
Available Formats
Download as ODP, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views

The Server-Side Javascript: Veera

This document provides an overview of Node.js, describing it as an open source server environment that uses JavaScript and runs on various platforms, highlighting how Node.js is asynchronous and single-threaded which allows it to handle a large number of concurrent connections more efficiently than traditional Apache servers. Key aspects covered include the Node.js architecture, event loop, blocking vs non-blocking I/O, performance benchmarks, and instructions for downloading, installing, and creating a simple example Node.js program.

Uploaded by

bhadri1255
Copyright
© © All Rights Reserved
Available Formats
Download as ODP, PDF, TXT or read online on Scribd
You are on page 1/ 15

The Server-side JavaScript

Veera
Overview
 What is Node.js?
 Why Node.js?

 What can Node.js do?

 Architecture

 Node.js Event Loop

 Blocking vs Non-Blocking

 Node.js vs Apache

 Node.js Performance Benchmarks

 Download and Install

 Example Program

 Q &A
What is Node.js?
 Node.js is an open source server environment
 Node.js runs on various platforms (Windows, Linux, Unix,

Mac OS X, etc.)
 Node.js uses JavaScript on the server
 Created by Ryan Dahl starting in 2009
 JavaScript runtime environment running Google Chrome’s

V8 engine
 In ‘Node.js’ , ‘.js’ doesn’t mean that its solely written

JavaScript. It is combination of JS, C and C++


Why Node.js?

 Node.js uses asynchronous programming!


 Node.js runs single-threaded
 Non-blocking
 Lightweight and Very Fast
What can Node.js do?

 Generate dynamic page content


 Create, open, read, write, delete, and close files on the server
 Collect form data
 Add, delete, modify data in your database
Node.js Architecture
Node.js Event Loop
Blocking vs Non-Blocking I/O
Blocking vs Non-Blocking I/O
 Traditional or Blocking I/O
var r e s u l t = db. query(‘ select x from t a b l e _ Y ‛ ) ;
doSomethingWith(result); / / w a i t f o r r e s u l t !
doSomethingWithOutResult(); / / execut ion i s blocked!

 Non-traditional or Non-blocking I/O


var r e s u l t = db. query(‘ select x from t a b l e _ Y ‛ ) ;
db. query(‘ select x from t able_Y ’ , f unct ion ( r e s u l t ) {
doSomethingWith(result); / / w a i t f o r r e s u l t !
});
doSomethingWithOutResul t ( ) ; / / executes wit hout any delay!
Node.js vs Apache
 It's faster
 It can handle tons of concurrent requests

Platform Number of request per second

PHP ( via Apache) 3,18,727

Node.js 5,56,930
Node.js Performance Benchmark

Octane2 Node.js scores. The NPM module “benchmark-octane2” was


used for this tests.

MacBook Pro 2016 (2,7 Ghz Intel Core i7, 16GB RAM — LPDDR3)
Download and Install
 Download and install from “https://nodejs.org”
 Node.js heavily relies on modules

 Creating a module is easy, just put your JavaScript

code in a separate js file and include it in your code


by using keyword require, like:
var modulex = require(‘./modulex’);
 Libraries in Node.js are called packages and they

can be installed by typing


npm i n s t a l l package_name
Example Program

You might also like