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