© 2017 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
NODE.JS | Introduction & Basics
Kanika Gera
© 2017 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Agenda
• Why Node.jS?
• What is Node.js?
• Architecture of Node.js
• Evented I/O
• Node.js Event Loop
• Where to use Node JS
• Demo
© 2017 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Why Node.JS?
3
• Provide Easy Way to Build Scalable
Network Programs
© 2017 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
What is a Node.JS?
4
• Server Side JavaScript
• Platform built on Chrome’s JavaScript runtime i.e. V8 script engine
• Lightweight and Efficient
• Event-Driven, works on the Non-Blocking Model
• Can Handle Thousands of Concurrent Connections with Minimal Overhead on a Single Process.
© 2017 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Run JavaScript on Server Side
Allows to run Javascript code in the backend,
outside a browser.
Using Google’s V8 Engine
Has Runtime environments and NPM library.
© 2017 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
What is a Node.JS?
6
© 2017 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Synchronous vs Asynchronous
7
Synchronous Asynchronous
Waits for each operation to
complete, after that executes next
operation.
Never waits each operation to
complete, executes all at one time.
Results handled as available.
Step by Step execution Callbacks used to handle results
© 2017 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Synchronous Example
8
© 2017 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Asynchronous Example
9
© 2017 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Single Thread, Synchronous I/O
© 2017 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Multiple Thread, Synchronous I/O
© 2017 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Single Thread, Asynchronous I/O
© 2017 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Single Thread, Asynchronous I/O
© 2017 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Event Loop
© 2017 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Event Loop
© 2017 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Non – Blocking I/O
© 2017 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Non – Blocking I/O
• Use Events
• Never wait for I/O
• I/O is expensive
© 2017 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Where to Use Node.JS?
18
• Few CPU Cycles
• I/O Operations
• Chat/ messaging
• Real – Time Applications
• Communication Hubs
• High Concurrency Applications
© 2017 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Where You Cannot Use Node.JS?
19
• Heavy Computation
• Large and Complicated Web Applications
© 2017 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Getting Started
20
• http://nodejs.org
• Download tar.gz
• Extract to a directory
• $ ./configure
• $ make install
© 2017 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
DEMO
21
© 2017 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Who Uses Node.Js?
22
© 2017 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
THANK YOU !
Node.Js: Basics Concepts and Introduction

Node.Js: Basics Concepts and Introduction

  • 1.
    © 2017 AdobeSystems Incorporated. All Rights Reserved. Adobe Confidential. NODE.JS | Introduction & Basics Kanika Gera
  • 2.
    © 2017 AdobeSystems Incorporated. All Rights Reserved. Adobe Confidential. Agenda • Why Node.jS? • What is Node.js? • Architecture of Node.js • Evented I/O • Node.js Event Loop • Where to use Node JS • Demo
  • 3.
    © 2017 AdobeSystems Incorporated. All Rights Reserved. Adobe Confidential. Why Node.JS? 3 • Provide Easy Way to Build Scalable Network Programs
  • 4.
    © 2017 AdobeSystems Incorporated. All Rights Reserved. Adobe Confidential. What is a Node.JS? 4 • Server Side JavaScript • Platform built on Chrome’s JavaScript runtime i.e. V8 script engine • Lightweight and Efficient • Event-Driven, works on the Non-Blocking Model • Can Handle Thousands of Concurrent Connections with Minimal Overhead on a Single Process.
  • 5.
    © 2017 AdobeSystems Incorporated. All Rights Reserved. Adobe Confidential. Run JavaScript on Server Side Allows to run Javascript code in the backend, outside a browser. Using Google’s V8 Engine Has Runtime environments and NPM library.
  • 6.
    © 2017 AdobeSystems Incorporated. All Rights Reserved. Adobe Confidential. What is a Node.JS? 6
  • 7.
    © 2017 AdobeSystems Incorporated. All Rights Reserved. Adobe Confidential. Synchronous vs Asynchronous 7 Synchronous Asynchronous Waits for each operation to complete, after that executes next operation. Never waits each operation to complete, executes all at one time. Results handled as available. Step by Step execution Callbacks used to handle results
  • 8.
    © 2017 AdobeSystems Incorporated. All Rights Reserved. Adobe Confidential. Synchronous Example 8
  • 9.
    © 2017 AdobeSystems Incorporated. All Rights Reserved. Adobe Confidential. Asynchronous Example 9
  • 10.
    © 2017 AdobeSystems Incorporated. All Rights Reserved. Adobe Confidential. Single Thread, Synchronous I/O
  • 11.
    © 2017 AdobeSystems Incorporated. All Rights Reserved. Adobe Confidential. Multiple Thread, Synchronous I/O
  • 12.
    © 2017 AdobeSystems Incorporated. All Rights Reserved. Adobe Confidential. Single Thread, Asynchronous I/O
  • 13.
    © 2017 AdobeSystems Incorporated. All Rights Reserved. Adobe Confidential. Single Thread, Asynchronous I/O
  • 14.
    © 2017 AdobeSystems Incorporated. All Rights Reserved. Adobe Confidential. Event Loop
  • 15.
    © 2017 AdobeSystems Incorporated. All Rights Reserved. Adobe Confidential. Event Loop
  • 16.
    © 2017 AdobeSystems Incorporated. All Rights Reserved. Adobe Confidential. Non – Blocking I/O
  • 17.
    © 2017 AdobeSystems Incorporated. All Rights Reserved. Adobe Confidential. Non – Blocking I/O • Use Events • Never wait for I/O • I/O is expensive
  • 18.
    © 2017 AdobeSystems Incorporated. All Rights Reserved. Adobe Confidential. Where to Use Node.JS? 18 • Few CPU Cycles • I/O Operations • Chat/ messaging • Real – Time Applications • Communication Hubs • High Concurrency Applications
  • 19.
    © 2017 AdobeSystems Incorporated. All Rights Reserved. Adobe Confidential. Where You Cannot Use Node.JS? 19 • Heavy Computation • Large and Complicated Web Applications
  • 20.
    © 2017 AdobeSystems Incorporated. All Rights Reserved. Adobe Confidential. Getting Started 20 • http://nodejs.org • Download tar.gz • Extract to a directory • $ ./configure • $ make install
  • 21.
    © 2017 AdobeSystems Incorporated. All Rights Reserved. Adobe Confidential. DEMO 21
  • 22.
    © 2017 AdobeSystems Incorporated. All Rights Reserved. Adobe Confidential. Who Uses Node.Js? 22
  • 23.
    © 2017 AdobeSystems Incorporated. All Rights Reserved. Adobe Confidential. THANK YOU !

Editor's Notes

  • #2  ----- Meeting Notes (8/24/17 13:58) ----- * Node.js is an open source server framework * Node.js is free * Node.js runs on various platforms (Windows, Linux, Unix, Mac OS X, etc.) * Node.js uses JavaScript on the server What Can Node.JS Do? * Node.js can generate dynamic page content * Node.js can create, open, read, write, delete, and close files on the server * Node.js can collect form data * Node.js can add, delete, modify data in your database What is a Node.js File? * Node.js files contain tasks that will be executed on certain events * A typical event is someone 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"
  • #6 Event Loop is a queue of callback function. When an Async function execute, the callback function is pushed into the queue,
  • #15 Event Loop is a queue of callback function. When an Async function execute, the callback function is pushed into the queue,
  • #16 Event Loop is a queue of callback function. When an Async function execute, the callback function is pushed into the queue,
  • #17 Event Loop is a queue of callback function. When an Async function execute, the callback function is pushed into the queue,
  • #18 Event Loop is a queue of callback function. When an Async function execute, the callback function is pushed into the queue,