SlideShare a Scribd company logo
1 of 26
Using Node to build scalable
server component
Who are we?
Andhy Koesnandar
MBA – UW Foster, MS CS – Nebraska
7+ years software development @Bing,
Azure and Microsoft Dynamics
Oby Sumampouw
MS CS – Stanford
6+ years distributed computing and
engagement hacker @LinkedIn and @oracle
About Cermati
• Financial product comparison site
• location based credit card promotions
What is this talk about
Node JS
• Run JS on Server
• Single threaded
Express JS
• MVC Web Library for Node.Js
Why should you care
• Its Javascript and this is JakartaJS
• Javascript is fun
• Uses unified language across the stack
• Its lightweight and its super fast
“Ruby is like a minivan, with all the features and Node is like a Ferrari –
crazy efficient and fast”
Sri Viswanath, SVP Engineering Groupon
Node Architecture
Its Single Thread app…
• Enter mighty Event Loop (libuv)
Client
Event loop
(main thread)
C++
Threadpool
(worker
threads)
Clients send HTTP requests
to Node.js server
An Event-loop is woken up by OS,
passes request and response objects
to the thread-pool
Long-running jobs run
on worker threads
I/O latency Pyramid
• L1: 3 cycles
• L2: 14 cycles
• RAM: 250 cycles
• DISK: 41,000,000 cycles
• NETWORK: 240,000,000 cycles
Apache vs nginx request / sec
Memory consumption in Apache vs nginx
What it means in code
• Traditional I/O
var result = db.query(“select x from table_Y”);
doSomethingWith(result); //wait for result!
doSomethingWithOutResult(); //execution is blocked!
• Non-traditional, Non-blocking I/O
db.query(“select x from table_Y”,function (result){
doSomethingWith(result); //wait for result!
});
doSomethingWithOutResult(); //executes without any delay!
Express JS
• The de-facto standard for the majority of Node.js web application
• Example:
Scaling Node
• Offload to Http proxy server
• Http caching Static Files
• Gzip compression
• SSL
• Application Scaling
• Worker Roles
• Node clustering
• Cluster Round Robin Load Balancing
Background Tasks
• Spawn child process that can run on the background
Node Clustering
• Can take advantage of multi core machines
• Load balance across multiple processes
• Increase throughput
No Clustering With Clustering
Node Clustering Round Robin
• Algorithm to choose in 0.10 is doesn’t let everyone to party
• Choose the process in round robin fashion
• New in 0.12
• That way everyone gets to party
When not to use Node?
• CPU Hungry applications. Not much I/O
• Video transcoding
• Encryption software
• AI and Machine learning
• You use relational DB
• There is no mature ORM yet for Node
• Current popular packages:
• Sequelize
• Node ORM2
Who uses Node
Source Code Available on GitHub
• https://github.com/akoesnan/express-cluster-tutorial
Nerds, questions?

More Related Content

What's hot

What's hot (20)

Create Rest API in Nodejs
Create Rest API in Nodejs Create Rest API in Nodejs
Create Rest API in Nodejs
 
Something about node basics
Something about node basicsSomething about node basics
Something about node basics
 
Node.js primer
Node.js primerNode.js primer
Node.js primer
 
Introduction to REST API with Node.js
Introduction to REST API with Node.jsIntroduction to REST API with Node.js
Introduction to REST API with Node.js
 
The MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.js
The MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.jsThe MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.js
The MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.js
 
Nodejs
NodejsNodejs
Nodejs
 
Introduction to node.js
Introduction to node.jsIntroduction to node.js
Introduction to node.js
 
Part One: Building Web Apps with the MERN Stack
Part One: Building Web Apps with the MERN StackPart One: Building Web Apps with the MERN Stack
Part One: Building Web Apps with the MERN Stack
 
MongoDB
MongoDBMongoDB
MongoDB
 
Back to the future with static site generators
Back to the future with static site generatorsBack to the future with static site generators
Back to the future with static site generators
 
Complete MVC on NodeJS
Complete MVC on NodeJSComplete MVC on NodeJS
Complete MVC on NodeJS
 
MEAN stack
MEAN stackMEAN stack
MEAN stack
 
Introduction to mean stack
Introduction to mean stackIntroduction to mean stack
Introduction to mean stack
 
Node.js Crash Course
Node.js Crash CourseNode.js Crash Course
Node.js Crash Course
 
Get MEAN! Node.js and the MEAN stack
Get MEAN!  Node.js and the MEAN stackGet MEAN!  Node.js and the MEAN stack
Get MEAN! Node.js and the MEAN stack
 
Альона Тудан " Життя QA в ажурі"
Альона Тудан " Життя QA в ажурі"Альона Тудан " Життя QA в ажурі"
Альона Тудан " Життя QA в ажурі"
 
Understand How Node.js and Core Features Works
Understand How Node.js and Core Features WorksUnderstand How Node.js and Core Features Works
Understand How Node.js and Core Features Works
 
node.js dao
node.js daonode.js dao
node.js dao
 
Functional Programming in Serverless World (Serveless UG Poland)
Functional Programming in Serverless World (Serveless UG Poland)Functional Programming in Serverless World (Serveless UG Poland)
Functional Programming in Serverless World (Serveless UG Poland)
 
Masterin Large Scale Java Script Applications
Masterin Large Scale Java Script ApplicationsMasterin Large Scale Java Script Applications
Masterin Large Scale Java Script Applications
 

Similar to Scalable server component using NodeJS & ExpressJS

Intro to node and mongodb 1
Intro to node and mongodb   1Intro to node and mongodb   1
Intro to node and mongodb 1
Mohammad Qureshi
 
Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)
Ran Mizrahi
 

Similar to Scalable server component using NodeJS & ExpressJS (20)

introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
 
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)
 
Tech io nodejs_20130531_v0.6
Tech io nodejs_20130531_v0.6Tech io nodejs_20130531_v0.6
Tech io nodejs_20130531_v0.6
 
Intro to node and mongodb 1
Intro to node and mongodb   1Intro to node and mongodb   1
Intro to node and mongodb 1
 
JavaScript Event Loop
JavaScript Event LoopJavaScript Event Loop
JavaScript Event Loop
 
Introduction to Node JS.pdf
Introduction to Node JS.pdfIntroduction to Node JS.pdf
Introduction to Node JS.pdf
 
Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)
 
Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)
 
Node azure
Node azureNode azure
Node azure
 
18_Node.js.ppt
18_Node.js.ppt18_Node.js.ppt
18_Node.js.ppt
 
18_Node.js.ppt
18_Node.js.ppt18_Node.js.ppt
18_Node.js.ppt
 
Beginners Node.js
Beginners Node.jsBeginners Node.js
Beginners Node.js
 
Practical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.jsPractical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.js
 
Node.js on Azure
Node.js on AzureNode.js on Azure
Node.js on Azure
 
What is Mean Stack Development ?
What is Mean Stack Development ?What is Mean Stack Development ?
What is Mean Stack Development ?
 
Introduction to Node.js: What, why and how?
Introduction to Node.js: What, why and how?Introduction to Node.js: What, why and how?
Introduction to Node.js: What, why and how?
 
Advanced Web Technology.pptx
Advanced Web Technology.pptxAdvanced Web Technology.pptx
Advanced Web Technology.pptx
 
Node.js
Node.jsNode.js
Node.js
 
NodeJS Concurrency
NodeJS ConcurrencyNodeJS Concurrency
NodeJS Concurrency
 
Nodejs
NodejsNodejs
Nodejs
 

Recently uploaded

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Recently uploaded (20)

Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 

Scalable server component using NodeJS & ExpressJS

  • 1. Using Node to build scalable server component
  • 2. Who are we? Andhy Koesnandar MBA – UW Foster, MS CS – Nebraska 7+ years software development @Bing, Azure and Microsoft Dynamics Oby Sumampouw MS CS – Stanford 6+ years distributed computing and engagement hacker @LinkedIn and @oracle
  • 3. About Cermati • Financial product comparison site • location based credit card promotions
  • 4. What is this talk about Node JS • Run JS on Server • Single threaded Express JS • MVC Web Library for Node.Js
  • 5. Why should you care • Its Javascript and this is JakartaJS • Javascript is fun • Uses unified language across the stack • Its lightweight and its super fast “Ruby is like a minivan, with all the features and Node is like a Ferrari – crazy efficient and fast” Sri Viswanath, SVP Engineering Groupon
  • 7. Its Single Thread app… • Enter mighty Event Loop (libuv) Client Event loop (main thread) C++ Threadpool (worker threads) Clients send HTTP requests to Node.js server An Event-loop is woken up by OS, passes request and response objects to the thread-pool Long-running jobs run on worker threads
  • 8. I/O latency Pyramid • L1: 3 cycles • L2: 14 cycles • RAM: 250 cycles • DISK: 41,000,000 cycles • NETWORK: 240,000,000 cycles
  • 9. Apache vs nginx request / sec
  • 10. Memory consumption in Apache vs nginx
  • 11.
  • 12.
  • 13. What it means in code • Traditional I/O var result = db.query(“select x from table_Y”); doSomethingWith(result); //wait for result! doSomethingWithOutResult(); //execution is blocked! • Non-traditional, Non-blocking I/O db.query(“select x from table_Y”,function (result){ doSomethingWith(result); //wait for result! }); doSomethingWithOutResult(); //executes without any delay!
  • 14. Express JS • The de-facto standard for the majority of Node.js web application • Example:
  • 15. Scaling Node • Offload to Http proxy server • Http caching Static Files • Gzip compression • SSL • Application Scaling • Worker Roles • Node clustering • Cluster Round Robin Load Balancing
  • 16. Background Tasks • Spawn child process that can run on the background
  • 17. Node Clustering • Can take advantage of multi core machines • Load balance across multiple processes • Increase throughput
  • 18.
  • 19.
  • 20. No Clustering With Clustering
  • 21.
  • 22. Node Clustering Round Robin • Algorithm to choose in 0.10 is doesn’t let everyone to party • Choose the process in round robin fashion • New in 0.12 • That way everyone gets to party
  • 23. When not to use Node? • CPU Hungry applications. Not much I/O • Video transcoding • Encryption software • AI and Machine learning • You use relational DB • There is no mature ORM yet for Node • Current popular packages: • Sequelize • Node ORM2
  • 25. Source Code Available on GitHub • https://github.com/akoesnan/express-cluster-tutorial

Editor's Notes

  1. Node.js uses an event-driven, non-blocking I/O model, which makes it lightweight. (from nodejs.org!) It makes use of event-loops via JavaScript’s callback functionality to implement the non-blocking I/O. Programs for Node.js are written in JavaScript but not in the same JavaScript we are use to. There is no DOM implementation provided by Node.js, i.e. you can not do this: var element = document.getElementById(“elementId”); Everything inside Node.js runs in a single-thread.
  2. EventMachine (Ruby) or Python’s Twisted or Perl’s AnyEvent framework
  3. Better software can multitask. Other threads of execution can run while waiting.