SlideShare a Scribd company logo
1 of 28
Node.js Learning Kit
Vipin Menon, Software Engineer, IBM
vipinmv1@in.ibm.com | @vipinmv | https://github.com/vipinmenon
Agenda
Introduction to Basic APIs and best practices.
Streams Buffers
Cluster Modules
Timers JSON
NPM Addons
stream - definition
Flowing data; perfect match for event architecture
stream – best practices
 Know your (data) producer, consumer and
backpressure
stream – best practices
 There are number of life cycle events for streams;
knowing and using those leads to efficient program
 Streams do not define data types, it flows your data as
is
buffer - definition
An abstraction around raw binary data
buffer - example
buffer – best practices
 Buffer is great for manipulating large in-memory data
 With `allocUnsafe()`, raw memory is exposed, so use it
with caution
 Buffer implies (large) memory, track your objects
cluster - definition
Share server load, exploit multiple cores
cluster - example
Master
Worker
cluster – best practices
 Use for single server multi-core exploitation; when load
grows beyond threshold, switch to horizontal scaling
 Don’t mix cluster with child_process – it adds complexity
 Session is not managed automatically, app needs to
implement one
modules - definition
Re-usable API abstractions
modules - example
modules – best practices
 Hide complexities under well defined APIs
 Avoid global state; avoid side effects (`process.exit`)
 Use discrete, disambiguating naming convention
timers - definition
Schedulers: Global APIs for future execution
timers - example
timers – best practices
 Don’t cover up program bugs with artificial delays
 `setInterval` is a recurring schedule, know when to shut
those down
 Don’t write code that critically rely on schedule precision
JSON - definition
 JavaScript Object Notation
 Data interchange format, native to JavaScript
 Specification for JS Object Marshalling / Unmarshalling
JSON - example
JSON – best practices
 Using a schema improves readability and speed
 Use shorter field names for serializable objects
 JSON processing is synchronous, so large (> 2 MB)
throttles the Node.js thread
NPM - definition
 Most popular JavaScript development tool registry
 Default Package manager for Node.js
npm - example
npm – best practices
 Known your modules! Audit and scan third party
modules periodically
 Use active and well maintained modules
 Lock your module dependencies
addons - definition
Foreign Function Interfacing; mainly C++
addons - example
addons – best practices
 Don’t directly deal with V8, use wrappers
 Addons run on main thread, don’t run tight loop code
 Many addon resources are not visible to Node.js so
use those under your control
Disclaimer
 The information contained in this presentation is provided for informational purposes only.
 While efforts were made to verify the completeness and accuracy of the information contained
in this presentation, it is provided “As Is”, without warranty of any kind, express or implied.
 In addition, this information is based on IBM’s current product plans and strategy, which are
subject to change by IBM without notice.
 IBM shall not be responsible for any damages arising out of the use of, or otherwise related to,
this presentation or any other documentation.
 Nothing contained in this presentation is intended to, or shall have the effect of:
 Creating any warranty or representation from IBM (or its affiliates or its or their supplies
and/or licensors); or
 Altering the terms and conditions of the applicable license agreement governing the use
of IBM software.
THANK YOU!

More Related Content

What's hot

What's hot (12)

How to speed up your website
How to speed up your websiteHow to speed up your website
How to speed up your website
 
Performance Optimization in Large Systems - Cusec 2019
Performance Optimization in Large Systems - Cusec 2019Performance Optimization in Large Systems - Cusec 2019
Performance Optimization in Large Systems - Cusec 2019
 
Caching for Cash, part 4 DPC 2009
Caching for Cash, part 4 DPC 2009Caching for Cash, part 4 DPC 2009
Caching for Cash, part 4 DPC 2009
 
Frontend Caching - The "new" frontier
Frontend Caching - The "new" frontierFrontend Caching - The "new" frontier
Frontend Caching - The "new" frontier
 
Geek Sessions Talk
Geek Sessions TalkGeek Sessions Talk
Geek Sessions Talk
 
AWS Lambdas are cool - Cheminfo Stories Day 1
AWS Lambdas are cool - Cheminfo Stories Day 1AWS Lambdas are cool - Cheminfo Stories Day 1
AWS Lambdas are cool - Cheminfo Stories Day 1
 
High Availabiltity & Replica Sets with mongoDB
High Availabiltity & Replica Sets with mongoDBHigh Availabiltity & Replica Sets with mongoDB
High Availabiltity & Replica Sets with mongoDB
 
WordCamp RVA
WordCamp RVAWordCamp RVA
WordCamp RVA
 
dh-slides-perf.ppt
dh-slides-perf.pptdh-slides-perf.ppt
dh-slides-perf.ppt
 
Let the Tiger Roar!
Let the Tiger Roar!Let the Tiger Roar!
Let the Tiger Roar!
 
Managing and Scaling Puppet - PuppetConf 2014
Managing and Scaling Puppet - PuppetConf 2014Managing and Scaling Puppet - PuppetConf 2014
Managing and Scaling Puppet - PuppetConf 2014
 
Redis part 2
Redis part 2Redis part 2
Redis part 2
 

Similar to Essentials nodejs learning kit

Optimizing your java applications for multi core hardware
Optimizing your java applications for multi core hardwareOptimizing your java applications for multi core hardware
Optimizing your java applications for multi core hardware
IndicThreads
 
scale_perf_best_practices
scale_perf_best_practicesscale_perf_best_practices
scale_perf_best_practices
webuploader
 
Scaling Web Apps P Falcone
Scaling Web Apps P FalconeScaling Web Apps P Falcone
Scaling Web Apps P Falcone
jedt
 
Usemon; Building The Big Brother Of The Java Virtual Machinve
Usemon; Building The Big Brother Of The Java Virtual MachinveUsemon; Building The Big Brother Of The Java Virtual Machinve
Usemon; Building The Big Brother Of The Java Virtual Machinve
Paul René Jørgensen
 

Similar to Essentials nodejs learning kit (20)

Node js meetup
Node js meetupNode js meetup
Node js meetup
 
Best practice adoption (and lack there of)
Best practice adoption (and lack there of)Best practice adoption (and lack there of)
Best practice adoption (and lack there of)
 
Optimizing your java applications for multi core hardware
Optimizing your java applications for multi core hardwareOptimizing your java applications for multi core hardware
Optimizing your java applications for multi core hardware
 
Node.js security tour
Node.js security tourNode.js security tour
Node.js security tour
 
MongoDB at MapMyFitness
MongoDB at MapMyFitnessMongoDB at MapMyFitness
MongoDB at MapMyFitness
 
Drools & jBPM Info Sheet
Drools & jBPM Info SheetDrools & jBPM Info Sheet
Drools & jBPM Info Sheet
 
Node JS - A brief overview on building real-time web applications
Node JS - A brief overview on building real-time web applicationsNode JS - A brief overview on building real-time web applications
Node JS - A brief overview on building real-time web applications
 
[AWS Dev Day] 인공지능 / 기계 학습 | AWS 기반 기계 학습 자동화 및 최적화를 위한 실전 기법 - 남궁영환 AWS 솔루션...
[AWS Dev Day] 인공지능 / 기계 학습 |  AWS 기반 기계 학습 자동화 및 최적화를 위한 실전 기법 - 남궁영환 AWS 솔루션...[AWS Dev Day] 인공지능 / 기계 학습 |  AWS 기반 기계 학습 자동화 및 최적화를 위한 실전 기법 - 남궁영환 AWS 솔루션...
[AWS Dev Day] 인공지능 / 기계 학습 | AWS 기반 기계 학습 자동화 및 최적화를 위한 실전 기법 - 남궁영환 AWS 솔루션...
 
Performance on a budget
Performance on a budgetPerformance on a budget
Performance on a budget
 
How Netflix Tunes Amazon EC2 Instances for Performance - CMP325 - re:Invent 2017
How Netflix Tunes Amazon EC2 Instances for Performance - CMP325 - re:Invent 2017How Netflix Tunes Amazon EC2 Instances for Performance - CMP325 - re:Invent 2017
How Netflix Tunes Amazon EC2 Instances for Performance - CMP325 - re:Invent 2017
 
Web Speed And Scalability
Web Speed And ScalabilityWeb Speed And Scalability
Web Speed And Scalability
 
scale_perf_best_practices
scale_perf_best_practicesscale_perf_best_practices
scale_perf_best_practices
 
Perfomatix - NodeJS Coding Standards
Perfomatix - NodeJS Coding StandardsPerfomatix - NodeJS Coding Standards
Perfomatix - NodeJS Coding Standards
 
071410 sun a_1515_feldman_stephen
071410 sun a_1515_feldman_stephen071410 sun a_1515_feldman_stephen
071410 sun a_1515_feldman_stephen
 
Planning For High Performance Web Application
Planning For High Performance Web ApplicationPlanning For High Performance Web Application
Planning For High Performance Web Application
 
journal for research
journal for researchjournal for research
journal for research
 
Scaling Web Apps P Falcone
Scaling Web Apps P FalconeScaling Web Apps P Falcone
Scaling Web Apps P Falcone
 
Usemon; Building The Big Brother Of The Java Virtual Machinve
Usemon; Building The Big Brother Of The Java Virtual MachinveUsemon; Building The Big Brother Of The Java Virtual Machinve
Usemon; Building The Big Brother Of The Java Virtual Machinve
 
Java on Rails SV Code Camp 2014
Java on Rails SV Code Camp 2014Java on Rails SV Code Camp 2014
Java on Rails SV Code Camp 2014
 
Beginners Node.js
Beginners Node.jsBeginners Node.js
Beginners Node.js
 

Recently uploaded

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Recently uploaded (20)

TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
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...
 
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
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 

Essentials nodejs learning kit

  • 1. Node.js Learning Kit Vipin Menon, Software Engineer, IBM vipinmv1@in.ibm.com | @vipinmv | https://github.com/vipinmenon
  • 2. Agenda Introduction to Basic APIs and best practices. Streams Buffers Cluster Modules Timers JSON NPM Addons
  • 3. stream - definition Flowing data; perfect match for event architecture
  • 4. stream – best practices  Know your (data) producer, consumer and backpressure
  • 5. stream – best practices  There are number of life cycle events for streams; knowing and using those leads to efficient program  Streams do not define data types, it flows your data as is
  • 6. buffer - definition An abstraction around raw binary data
  • 8. buffer – best practices  Buffer is great for manipulating large in-memory data  With `allocUnsafe()`, raw memory is exposed, so use it with caution  Buffer implies (large) memory, track your objects
  • 9. cluster - definition Share server load, exploit multiple cores
  • 11. cluster – best practices  Use for single server multi-core exploitation; when load grows beyond threshold, switch to horizontal scaling  Don’t mix cluster with child_process – it adds complexity  Session is not managed automatically, app needs to implement one
  • 12. modules - definition Re-usable API abstractions
  • 14. modules – best practices  Hide complexities under well defined APIs  Avoid global state; avoid side effects (`process.exit`)  Use discrete, disambiguating naming convention
  • 15. timers - definition Schedulers: Global APIs for future execution
  • 17. timers – best practices  Don’t cover up program bugs with artificial delays  `setInterval` is a recurring schedule, know when to shut those down  Don’t write code that critically rely on schedule precision
  • 18. JSON - definition  JavaScript Object Notation  Data interchange format, native to JavaScript  Specification for JS Object Marshalling / Unmarshalling
  • 20. JSON – best practices  Using a schema improves readability and speed  Use shorter field names for serializable objects  JSON processing is synchronous, so large (> 2 MB) throttles the Node.js thread
  • 21. NPM - definition  Most popular JavaScript development tool registry  Default Package manager for Node.js
  • 23. npm – best practices  Known your modules! Audit and scan third party modules periodically  Use active and well maintained modules  Lock your module dependencies
  • 24. addons - definition Foreign Function Interfacing; mainly C++
  • 26. addons – best practices  Don’t directly deal with V8, use wrappers  Addons run on main thread, don’t run tight loop code  Many addon resources are not visible to Node.js so use those under your control
  • 27. Disclaimer  The information contained in this presentation is provided for informational purposes only.  While efforts were made to verify the completeness and accuracy of the information contained in this presentation, it is provided “As Is”, without warranty of any kind, express or implied.  In addition, this information is based on IBM’s current product plans and strategy, which are subject to change by IBM without notice.  IBM shall not be responsible for any damages arising out of the use of, or otherwise related to, this presentation or any other documentation.  Nothing contained in this presentation is intended to, or shall have the effect of:  Creating any warranty or representation from IBM (or its affiliates or its or their supplies and/or licensors); or  Altering the terms and conditions of the applicable license agreement governing the use of IBM software.