0% found this document useful (0 votes)
15 views15 pages

Introduction to Node.js Server-Side JavaScript

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
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODP, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views15 pages

Introduction to Node.js Server-Side JavaScript

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
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODP, PDF, TXT or read online on Scribd

The Server-side JavaScript

Veera
Overview
 What is [Link]?
 Why [Link]?

 What can [Link] do?

 Architecture

 [Link] Event Loop

 Blocking vs Non-Blocking

 [Link] vs Apache

 [Link] Performance Benchmarks

 Download and Install

 Example Program

 Q &A
What is [Link]?
 [Link] is an open source server environment
 [Link] runs on various platforms (Windows, Linux, Unix,

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

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

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


Why [Link]?

 [Link] uses asynchronous programming!


 [Link] runs single-threaded
 Non-blocking
 Lightweight and Very Fast
What can [Link] 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
[Link] Architecture
[Link] 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!
[Link] vs Apache
 It's faster
 It can handle tons of concurrent requests

Platform Number of request per second

PHP ( via Apache) 3,18,727

[Link] 5,56,930
[Link] Performance Benchmark

Octane2 [Link] 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 “[Link]
 [Link] 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 [Link] 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