SlideShare a Scribd company logo
NodeJS
Marcelo Serpa
About me
❏ Software Architect at ilegra
❏ AWS & GCP
❏ Google Cloud Architect Certified
❏ Microservices / DevOPS
❏ Mortal Kombat Player :D
❏ https://github.com/marceloserpa/
❏ https://www.linkedin.com/in/marceloserpa/
How works the traditional way
❏ thread per request model
❏ One thread for the entire request flow
How works the traditional way
❏ Waste resources with waiting threads
❏ Threads are expensive
❏ Limitations 1 thread == 1MB (around it)
❏ Operational System needs to
handle threads
❏ You need more hardware
Blocking and synchronous
❏ Sequential
❏ Unnecessary waiting time
❏ Total time is high
Restaurant … bad restaurant
Imagine:
❏ 1 chef per client
❏ The chef take an order
❏ The chef the cook the plate
❏ The chef accept payment
❏ Go to the next client
❏ … Is it make sense?
Restaurant … good restaurant
Imagine:
❏ 1 waiter and 1 cooker
❏ The waiter
❏ take the orders from many clients
❏ send orders to Cooker
❏ bring the plate to client from kitchen
❏ accept payment
❏ The Chef
❏ Cook the plates
Whats is NodeJS
❏ Platform built on top Chrome v8 engine
❏ Asynchronous event-driven
❏ Non-Blocking I/O
❏ Focused on network application
❏ Created by Ryan Dahl
❏ 05/27/2009
❏ Inspired by
❏ NGINX architecture
❏ Twisted
❏ Event Machine
❏ Reactor Pattern
Hello World!!!
Single Thread model
❏ One thread to handle requests
❏ Delegate I/O to Thread pool
❏ 0 thread waiting
NonBlocking and Asynchronous
❏ Initialize something now
❏ Using Threads Efficiently
❏ Scalability
❏ More efficient (doing more with less resources)
❏ Concurrency
Running Blocking code
Running NonBlocking code
Running NonBlocking code
Running NonBlocking code
Architecture
v8
❏ Engine open-source de JavaScript
❏ Created by Chrome Team
❏ Written in C++
❏ Implements ECMAScript and WebAssembly
❏ Compile JS to native machine code (JIT)
❏ Handle call stack
v8
Core modules - IO Libs
❏ Multithreading
❏ Starts Thread Pool with 4 threads
❏ Default libraries have version blocking for IO methods
❏ Built on top Libuv (Libeio e Libev)
❏ Each O.S have implementation of Event Demultiplexer:
❏ epoll - Linux
❏ kqueue - MacOSX
❏ events ports - Solaris
❏ I/O Completion Port API (IOCP) - Windows
Event Loop - internals
“The event loop is what allows Node.js to perform non-blocking I/O operations —
despite the fact that JavaScript is single-threaded — by offloading operations to
the system kernel whenever possible.”
source: https://nodejs.org/uk/docs/guides/event-loop-timers-and-nexttick/
Event Loop - internals
❏ 6 phases
❏ Each phase has FIFO queue of
callbacks
❏ Event loop move to next phase
when all queue has processed
❏ The poll phase are queued by
the kernel
Event Loop - internals
❏ timers: executes callbacks scheduled by setTimeout() and setInterval().
❏ pending callbacks: executes I/O callbacks deferred to the next loop
iteration.
❏ idle, prepare: only used internally.
❏ poll: retrieve new I/O events; execute I/O related callbacks (almost all with
the exception of close callbacks, the ones scheduled by timers, and
setImmediate()); node will block here when appropriate.
❏ check: setImmediate() callbacks are invoked here.
❏ close callbacks: some close callbacks, e.g. socket.on('close', ...).
Commons JS
❏ module specification
❏ used is a standard in NodeJS
❏ each file is a module
❏ loaded synchronously
❏ processed in order
Stream
❏ Streams are implements from EventEmitter
❏ Read chunks from data
❏ Perform specific tasks continuously
❏ Have support to create pipeline
❏ Two main advantages are:
❏ Reduce consuming of memory
❏ Time to processing large files
Stream sample
Stream sample
Handling POST request
Handling POST request
Cluster mode
❏ Maximize the CPU usage
❏ Fork node process
❏ Load balancing
Cluster mode
Cluster mode
Worker threads
❏ Enable us to create threads
❏ Useful for performing CPU-intensive
❏ Support: NodeJs 10.5
❏ Never use it for I/O Bound
Worker threads - define worker thread
Worker threads - invoking worker thread
Worker threads - results
NPM
❏ Node Package Manager
❏ Online repository
❏ Command-line utility
❏ Dependency Manager
❏ Install packages
❏ Basic commands
❏ npm init
❏ npm install <package> --save
❏ npm install <package> -g
NPM
NPM
Companies using NodeJS
❏ Paypal
❏ Ebay
❏ Sony Yahoo
❏ Amazon
❏ Netflix
❏ The New York Times
❏ Salesforce
❏ Linkedin
❏ Uber
Technologies based EventLoop architecture
When use ...
● Intensive I/O
● Low CPU processing
● NoSQL
❏ Intensive CPU**
❏ Relational Database
When avoid ...
Frontend Track NodeJS

More Related Content

What's hot (20)

PDF
Ansible
gnosek
 
PDF
Node.js for Rubists
Sagiv Ofek
 
PDF
Server-Side JavaScript Developement - Node.JS Quick Tour
q3boy
 
PDF
Node.js concurrency
Giacomo Fornari
 
PDF
Create a RESTful API with NodeJS, Express and MongoDB
Hengki Sihombing
 
PDF
CI and CD
Ladislav Prskavec
 
PPTX
Create Rest API in Nodejs
Irfan Maulana
 
PDF
Node.js
EU Edge
 
PDF
QCon 2017 - Java/JVM com Docker em produção: lições das trincheiras
Leonardo Zanivan
 
PDF
Node.js and How JavaScript is Changing Server Programming
Tom Croucher
 
PDF
Improving Development and Deployment with Docker
Irfad Razick
 
PDF
Xclone presentation final
Burning Lin
 
PPTX
GeekCampSG - Nodejs , Websockets and Realtime Web
Bhagaban Behera
 
PDF
Docker
Kamil Grabowski
 
PPTX
Basics of Node.js
Alper Unal
 
PDF
Node.js introduction
Prasoon Kumar
 
PPTX
CLI utility in ClojureScript running on Node.js
Karolis Labrencis
 
PDF
Storage based snapshots for KVM VMs in CloudStack
ShapeBlue
 
PDF
appborg, coffeesurgeon, moof, logging-system
endian7000
 
Ansible
gnosek
 
Node.js for Rubists
Sagiv Ofek
 
Server-Side JavaScript Developement - Node.JS Quick Tour
q3boy
 
Node.js concurrency
Giacomo Fornari
 
Create a RESTful API with NodeJS, Express and MongoDB
Hengki Sihombing
 
Create Rest API in Nodejs
Irfan Maulana
 
Node.js
EU Edge
 
QCon 2017 - Java/JVM com Docker em produção: lições das trincheiras
Leonardo Zanivan
 
Node.js and How JavaScript is Changing Server Programming
Tom Croucher
 
Improving Development and Deployment with Docker
Irfad Razick
 
Xclone presentation final
Burning Lin
 
GeekCampSG - Nodejs , Websockets and Realtime Web
Bhagaban Behera
 
Basics of Node.js
Alper Unal
 
Node.js introduction
Prasoon Kumar
 
CLI utility in ClojureScript running on Node.js
Karolis Labrencis
 
Storage based snapshots for KVM VMs in CloudStack
ShapeBlue
 
appborg, coffeesurgeon, moof, logging-system
endian7000
 

Similar to Frontend Track NodeJS (20)

PPTX
Node.js: A Guided Tour
cacois
 
PDF
Node js internal
Chinh Ngo Nguyen
 
PPTX
Proposal
Constantine Priemski
 
PDF
"Node.js vs workers — A comparison of two JavaScript runtimes", James M Snell
Fwdays
 
PPTX
Events for JavaScript event loop track.pptx
sontinenianuradha
 
PPTX
Node js
Fatih Şimşek
 
PPTX
How NOT to write in Node.js
Piotr Pelczar
 
PPT
18_Node.js.ppt
KhalilSalhi7
 
PDF
Tech io nodejs_20130531_v0.6
Ganesh Kondal
 
PPT
18_Node.js.ppt
MaulikShah516542
 
PPTX
Nodejs
Vinod Kumar Marupu
 
PPTX
Introduction to Node.js
Vikash Singh
 
PPTX
Introduction to NodeJS
Uttam Aaseri
 
PDF
Basic Understanding and Implement of Node.js
Gary Yeh
 
PPTX
Node
Ankit Chawla
 
PDF
Node in Real Time - The Beginning
Axilis
 
PPTX
introduction to node.js
orkaplan
 
PPTX
Beginners Node.js
Khaled Mosharraf
 
PPTX
Introduction to Node.js
NodeXperts
 
KEY
Playing With Fire - An Introduction to Node.js
Mike Hagedorn
 
Node.js: A Guided Tour
cacois
 
Node js internal
Chinh Ngo Nguyen
 
"Node.js vs workers — A comparison of two JavaScript runtimes", James M Snell
Fwdays
 
Events for JavaScript event loop track.pptx
sontinenianuradha
 
How NOT to write in Node.js
Piotr Pelczar
 
18_Node.js.ppt
KhalilSalhi7
 
Tech io nodejs_20130531_v0.6
Ganesh Kondal
 
18_Node.js.ppt
MaulikShah516542
 
Introduction to Node.js
Vikash Singh
 
Introduction to NodeJS
Uttam Aaseri
 
Basic Understanding and Implement of Node.js
Gary Yeh
 
Node in Real Time - The Beginning
Axilis
 
introduction to node.js
orkaplan
 
Beginners Node.js
Khaled Mosharraf
 
Introduction to Node.js
NodeXperts
 
Playing With Fire - An Introduction to Node.js
Mike Hagedorn
 
Ad

More from Marcelo Serpa (13)

PDF
AWS Organizations
Marcelo Serpa
 
PDF
Web 3.0 - The Future of Web
Marcelo Serpa
 
PDF
Netty training
Marcelo Serpa
 
PDF
Terraform
Marcelo Serpa
 
PDF
Cqrs
Marcelo Serpa
 
PDF
Microservices
Marcelo Serpa
 
PDF
Caching
Marcelo Serpa
 
PDF
Defenda seus consumidores
Marcelo Serpa
 
PDF
Service discovery with Eureka and Spring Cloud
Marcelo Serpa
 
PDF
Acessando apis com feign e hystrix
Marcelo Serpa
 
PDF
No core do node js - entendendo como a plataforma trabalha
Marcelo Serpa
 
PDF
Componentizacao com ReactJs
Marcelo Serpa
 
PDF
Clean code
Marcelo Serpa
 
AWS Organizations
Marcelo Serpa
 
Web 3.0 - The Future of Web
Marcelo Serpa
 
Netty training
Marcelo Serpa
 
Terraform
Marcelo Serpa
 
Microservices
Marcelo Serpa
 
Caching
Marcelo Serpa
 
Defenda seus consumidores
Marcelo Serpa
 
Service discovery with Eureka and Spring Cloud
Marcelo Serpa
 
Acessando apis com feign e hystrix
Marcelo Serpa
 
No core do node js - entendendo como a plataforma trabalha
Marcelo Serpa
 
Componentizacao com ReactJs
Marcelo Serpa
 
Clean code
Marcelo Serpa
 
Ad

Recently uploaded (20)

PPTX
Function & Procedure: Function Vs Procedure in PL/SQL
Shani Tiwari
 
PDF
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
PDF
AOMEI Partition Assistant Crack 10.8.2 + WinPE Free Downlaod New Version 2025
bashirkhan333g
 
PPTX
Prompt Like a Pro. Leveraging Salesforce Data to Power AI Workflows.pptx
Dele Amefo
 
PDF
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
PDF
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
PDF
UITP Summit Meep Pitch may 2025 MaaS Rebooted
campoamor1
 
PPTX
From spreadsheets and delays to real-time control
SatishKumar2651
 
PPTX
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
PDF
Best Web development company in india 2025
Greenusys
 
PDF
Everything you need to know about pricing & licensing Microsoft 365 Copilot f...
Q-Advise
 
PDF
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
PDF
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
PDF
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
PDF
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
PPTX
BB FlashBack Pro 5.61.0.4843 With Crack Free Download
cracked shares
 
PDF
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
PDF
intro_to_cpp_namespace_robotics_corner.pdf
MohamedSaied877003
 
PDF
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
PDF
Is Framer the Future of AI Powered No-Code Development?
Isla Pandora
 
Function & Procedure: Function Vs Procedure in PL/SQL
Shani Tiwari
 
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
AOMEI Partition Assistant Crack 10.8.2 + WinPE Free Downlaod New Version 2025
bashirkhan333g
 
Prompt Like a Pro. Leveraging Salesforce Data to Power AI Workflows.pptx
Dele Amefo
 
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
UITP Summit Meep Pitch may 2025 MaaS Rebooted
campoamor1
 
From spreadsheets and delays to real-time control
SatishKumar2651
 
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
Best Web development company in india 2025
Greenusys
 
Everything you need to know about pricing & licensing Microsoft 365 Copilot f...
Q-Advise
 
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
BB FlashBack Pro 5.61.0.4843 With Crack Free Download
cracked shares
 
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
intro_to_cpp_namespace_robotics_corner.pdf
MohamedSaied877003
 
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
Is Framer the Future of AI Powered No-Code Development?
Isla Pandora
 

Frontend Track NodeJS

  • 2. About me ❏ Software Architect at ilegra ❏ AWS & GCP ❏ Google Cloud Architect Certified ❏ Microservices / DevOPS ❏ Mortal Kombat Player :D ❏ https://github.com/marceloserpa/ ❏ https://www.linkedin.com/in/marceloserpa/
  • 3. How works the traditional way ❏ thread per request model ❏ One thread for the entire request flow
  • 4. How works the traditional way ❏ Waste resources with waiting threads ❏ Threads are expensive ❏ Limitations 1 thread == 1MB (around it) ❏ Operational System needs to handle threads ❏ You need more hardware
  • 5. Blocking and synchronous ❏ Sequential ❏ Unnecessary waiting time ❏ Total time is high
  • 6. Restaurant … bad restaurant Imagine: ❏ 1 chef per client ❏ The chef take an order ❏ The chef the cook the plate ❏ The chef accept payment ❏ Go to the next client ❏ … Is it make sense?
  • 7. Restaurant … good restaurant Imagine: ❏ 1 waiter and 1 cooker ❏ The waiter ❏ take the orders from many clients ❏ send orders to Cooker ❏ bring the plate to client from kitchen ❏ accept payment ❏ The Chef ❏ Cook the plates
  • 8. Whats is NodeJS ❏ Platform built on top Chrome v8 engine ❏ Asynchronous event-driven ❏ Non-Blocking I/O ❏ Focused on network application ❏ Created by Ryan Dahl ❏ 05/27/2009 ❏ Inspired by ❏ NGINX architecture ❏ Twisted ❏ Event Machine ❏ Reactor Pattern
  • 10. Single Thread model ❏ One thread to handle requests ❏ Delegate I/O to Thread pool ❏ 0 thread waiting
  • 11. NonBlocking and Asynchronous ❏ Initialize something now ❏ Using Threads Efficiently ❏ Scalability ❏ More efficient (doing more with less resources) ❏ Concurrency
  • 17. v8 ❏ Engine open-source de JavaScript ❏ Created by Chrome Team ❏ Written in C++ ❏ Implements ECMAScript and WebAssembly ❏ Compile JS to native machine code (JIT) ❏ Handle call stack
  • 18. v8
  • 19. Core modules - IO Libs ❏ Multithreading ❏ Starts Thread Pool with 4 threads ❏ Default libraries have version blocking for IO methods ❏ Built on top Libuv (Libeio e Libev) ❏ Each O.S have implementation of Event Demultiplexer: ❏ epoll - Linux ❏ kqueue - MacOSX ❏ events ports - Solaris ❏ I/O Completion Port API (IOCP) - Windows
  • 20. Event Loop - internals “The event loop is what allows Node.js to perform non-blocking I/O operations — despite the fact that JavaScript is single-threaded — by offloading operations to the system kernel whenever possible.” source: https://nodejs.org/uk/docs/guides/event-loop-timers-and-nexttick/
  • 21. Event Loop - internals ❏ 6 phases ❏ Each phase has FIFO queue of callbacks ❏ Event loop move to next phase when all queue has processed ❏ The poll phase are queued by the kernel
  • 22. Event Loop - internals ❏ timers: executes callbacks scheduled by setTimeout() and setInterval(). ❏ pending callbacks: executes I/O callbacks deferred to the next loop iteration. ❏ idle, prepare: only used internally. ❏ poll: retrieve new I/O events; execute I/O related callbacks (almost all with the exception of close callbacks, the ones scheduled by timers, and setImmediate()); node will block here when appropriate. ❏ check: setImmediate() callbacks are invoked here. ❏ close callbacks: some close callbacks, e.g. socket.on('close', ...).
  • 23. Commons JS ❏ module specification ❏ used is a standard in NodeJS ❏ each file is a module ❏ loaded synchronously ❏ processed in order
  • 24. Stream ❏ Streams are implements from EventEmitter ❏ Read chunks from data ❏ Perform specific tasks continuously ❏ Have support to create pipeline ❏ Two main advantages are: ❏ Reduce consuming of memory ❏ Time to processing large files
  • 29. Cluster mode ❏ Maximize the CPU usage ❏ Fork node process ❏ Load balancing
  • 32. Worker threads ❏ Enable us to create threads ❏ Useful for performing CPU-intensive ❏ Support: NodeJs 10.5 ❏ Never use it for I/O Bound
  • 33. Worker threads - define worker thread
  • 34. Worker threads - invoking worker thread
  • 35. Worker threads - results
  • 36. NPM ❏ Node Package Manager ❏ Online repository ❏ Command-line utility ❏ Dependency Manager ❏ Install packages ❏ Basic commands ❏ npm init ❏ npm install <package> --save ❏ npm install <package> -g
  • 37. NPM
  • 38. NPM
  • 39. Companies using NodeJS ❏ Paypal ❏ Ebay ❏ Sony Yahoo ❏ Amazon ❏ Netflix ❏ The New York Times ❏ Salesforce ❏ Linkedin ❏ Uber
  • 41. When use ... ● Intensive I/O ● Low CPU processing ● NoSQL ❏ Intensive CPU** ❏ Relational Database When avoid ...