SlideShare a Scribd company logo
1 of 29
21.02.2017
Fatih Şimşek - Software Infrastructure
NodeJs
Open Source, cross platform
Huge community
Ryan Dahl, Joyent
Developed in 2009
Published in 2011 ( Linux + Windows )
Similar design to systems like Ruby's Event Machine or
Python's Twisted
Who is using NodeJs?
Success Stories
Yahoo: Node services handle around 1.680.000 – 2.000.000
requests/minute. Biggest Win: speed & ease of developement
Netflix: The team decided to use Node.js to achieve lightweight,
modular and fast application. As a result, the startup time of
their new app has been reduced by 70%
Linkedin: When compared with the previous Ruby on Rails
based version, the new mobile app is up to 20 times faster
Walmart: %55 of all traffic on Black Friday went to Node
servers. Not a single Node server went down
Success Stories
PayPal: Build a Node version of a Java app in half the time with
fewer developers. Node version of the app doubled the number
of requests/second. Request time dropped 35%
Groupon: In comparison with earlier Ruby on Rails platform,
web pages got faster by about 50% and are able to serve much
higher traffic
GoDaddy: 10x fewer servers to host our customer websites and
we reduced the Time To First Byte (TTFB) considerably from
~60ms to something around ~12ms
Github
NodeJs
Built on Chrome’s Javascript Runtime (V8)
Single thread, event oriented
Event-Driven with Non-blocking I/O
Use a Event Loop for Non-blocking I/O
Can handle thousands of concurrent connections with minimal
overhead (CPU/Memory)
40% JS and 60% C++
Traditional Server
New thread per request
The thread is blocked
during IO operations
Thesis
IO is expensive
Thread per connection
is memory expensive
Architecture
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
Response is sent
back to main thread
via callback
Event loop returns
result to client
Architecture
API in Javascript
Relies on Google’s V8
runtime engine
Node Bindings allow for
server operations (IO,
network)
Libuv responsible for both
asynchronous I/O & event
loop
When to use NodeJs?
Highly Event driven & Heavily I/O bound
Chat application
Online game
Collaboration tool
Monitoring Dashboard
Trader’s Dashboard
When not to use NodeJs?
Heavy CPU intensive calculations on server-side
Concurrent Task based applications
Install
https://nodejs.org/en/download/
node –v (Node version)
Developement Environment
Web Storm
Sublime Text
Atom
Nodeclipse
Visual Studio
Visual Studio Code
DEMO
Node Frameworks & Tools
NPM (Package Manager)
Gulp / Grunt
Express.js
Frameworks built on Express.js (LoopBack / MEAN / Sails)
Restify
Mongoose
Socket.io
NPM
Package manager for Node
Bundled and installed automatically with the environment
Frequently Usage
• npm install --save package_name
• npm update
How Does it works?
• Read package.json
• Installs the dependencies in the local node_modules folder
• In global modes, it make a node module accessible to all
Express.js
Web application framework
Minimal and Flexible
Many Framework based on Express
Features
• MVC
• Routing
• Session Support
• Cookie Parsing
• Middleware (Request-Response Cycle)
• View Engines (Jade, Ejs, Vash)
Vash
Familiar Razor engine experience
No special template syntax to learn
Syntax:
Mongoose
Object Data Modelling for Node.js
Officially supported by 10gen,Inc
Features:
• Async and sync validation of models
• Model casting
• Object lifecycle management (hook save / validate)
• Query Builder
• Schema Deriven Design
DEMO
EventEmitter
Most of built-in Node libraries use it
Use Observer Pattern
Socket.io
Realtime application framework
Cross browser (Web socket + fallback)
Bi-directional communication
Automatic compression
IOS, Android, NativeScript support
Two parts
• Client side (run on browser)
• Server side (run on Node)
DEMO
Benchmark
Benchmark
Node js

More Related Content

What's hot

Introduction to node.js
Introduction to node.jsIntroduction to node.js
Introduction to node.jsDinesh U
 
NodeJS - Server Side JS
NodeJS - Server Side JS NodeJS - Server Side JS
NodeJS - Server Side JS Ganesh Kondal
 
An Introduction of Node Package Manager (NPM)
An Introduction of Node Package Manager (NPM)An Introduction of Node Package Manager (NPM)
An Introduction of Node Package Manager (NPM)iFour Technolab Pvt. Ltd.
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.jsRob O'Doherty
 
Basic Concept of Node.js & NPM
Basic Concept of Node.js & NPMBasic Concept of Node.js & NPM
Basic Concept of Node.js & NPMBhargav Anadkat
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.jsVikash Singh
 
Nodejs functions & modules
Nodejs functions & modulesNodejs functions & modules
Nodejs functions & modulesmonikadeshmane
 
What is Node.js | Node.js Tutorial for Beginners | Node.js Modules | Node.js ...
What is Node.js | Node.js Tutorial for Beginners | Node.js Modules | Node.js ...What is Node.js | Node.js Tutorial for Beginners | Node.js Modules | Node.js ...
What is Node.js | Node.js Tutorial for Beginners | Node.js Modules | Node.js ...Edureka!
 
Node.js Express Tutorial | Node.js Tutorial For Beginners | Node.js + Expres...
Node.js Express Tutorial | Node.js Tutorial For Beginners | Node.js +  Expres...Node.js Express Tutorial | Node.js Tutorial For Beginners | Node.js +  Expres...
Node.js Express Tutorial | Node.js Tutorial For Beginners | Node.js + Expres...Edureka!
 
Introduction to ReactJS
Introduction to ReactJSIntroduction to ReactJS
Introduction to ReactJSKnoldus Inc.
 
React JS - A quick introduction tutorial
React JS - A quick introduction tutorialReact JS - A quick introduction tutorial
React JS - A quick introduction tutorialMohammed Fazuluddin
 

What's hot (20)

Introduction to node.js
Introduction to node.jsIntroduction to node.js
Introduction to node.js
 
NodeJS - Server Side JS
NodeJS - Server Side JS NodeJS - Server Side JS
NodeJS - Server Side JS
 
Node js introduction
Node js introductionNode js introduction
Node js introduction
 
An Introduction of Node Package Manager (NPM)
An Introduction of Node Package Manager (NPM)An Introduction of Node Package Manager (NPM)
An Introduction of Node Package Manager (NPM)
 
Node js Introduction
Node js IntroductionNode js Introduction
Node js Introduction
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Basic Concept of Node.js & NPM
Basic Concept of Node.js & NPMBasic Concept of Node.js & NPM
Basic Concept of Node.js & NPM
 
Express js
Express jsExpress js
Express js
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Intro to React
Intro to ReactIntro to React
Intro to React
 
13 mongoose
13 mongoose13 mongoose
13 mongoose
 
Nodejs presentation
Nodejs presentationNodejs presentation
Nodejs presentation
 
Expressjs
ExpressjsExpressjs
Expressjs
 
Express node js
Express node jsExpress node js
Express node js
 
Nodejs functions & modules
Nodejs functions & modulesNodejs functions & modules
Nodejs functions & modules
 
What is Node.js | Node.js Tutorial for Beginners | Node.js Modules | Node.js ...
What is Node.js | Node.js Tutorial for Beginners | Node.js Modules | Node.js ...What is Node.js | Node.js Tutorial for Beginners | Node.js Modules | Node.js ...
What is Node.js | Node.js Tutorial for Beginners | Node.js Modules | Node.js ...
 
Node.js Express Tutorial | Node.js Tutorial For Beginners | Node.js + Expres...
Node.js Express Tutorial | Node.js Tutorial For Beginners | Node.js +  Expres...Node.js Express Tutorial | Node.js Tutorial For Beginners | Node.js +  Expres...
Node.js Express Tutorial | Node.js Tutorial For Beginners | Node.js + Expres...
 
Introduction to ReactJS
Introduction to ReactJSIntroduction to ReactJS
Introduction to ReactJS
 
React JS - A quick introduction tutorial
React JS - A quick introduction tutorialReact JS - A quick introduction tutorial
React JS - A quick introduction tutorial
 
React js
React jsReact js
React js
 

Similar to Node js

Building Applications With the MEAN Stack
Building Applications With the MEAN StackBuilding Applications With the MEAN Stack
Building Applications With the MEAN StackNir Noy
 
Kalp Corporate Node JS Perfect Guide
Kalp Corporate Node JS Perfect GuideKalp Corporate Node JS Perfect Guide
Kalp Corporate Node JS Perfect GuideKalp Corporate
 
Quick introduction to nodeJs
Quick introduction to nodeJsQuick introduction to nodeJs
Quick introduction to nodeJsAram Rafeq
 
Node.js Web Development .pdf
Node.js Web Development .pdfNode.js Web Development .pdf
Node.js Web Development .pdfAbanti Aazmin
 
GlobalsDB: Its significance for Node.js Developers
GlobalsDB: Its significance for Node.js DevelopersGlobalsDB: Its significance for Node.js Developers
GlobalsDB: Its significance for Node.js DevelopersRob Tweed
 
Day in a life of a node.js developer
Day in a life of a node.js developerDay in a life of a node.js developer
Day in a life of a node.js developerEdureka!
 
Day In A Life Of A Node.js Developer
Day In A Life Of A Node.js DeveloperDay In A Life Of A Node.js Developer
Day In A Life Of A Node.js DeveloperEdureka!
 
Node.js and .NET Core.pdf
Node.js and .NET Core.pdfNode.js and .NET Core.pdf
Node.js and .NET Core.pdfAppdeveloper10
 
Node.js Web Development.pdf
Node.js Web Development.pdfNode.js Web Development.pdf
Node.js Web Development.pdfSonia Simi
 
All You Need to Know About Using Node.pdf
All You Need to Know About Using Node.pdfAll You Need to Know About Using Node.pdf
All You Need to Know About Using Node.pdfiDataScientists
 
What is Node.js_ Where, When & How To Use It.pdf
What is Node.js_ Where, When & How To Use It.pdfWhat is Node.js_ Where, When & How To Use It.pdf
What is Node.js_ Where, When & How To Use It.pdfSmith Daniel
 

Similar to Node js (20)

Introduction to Node.JS
Introduction to Node.JSIntroduction to Node.JS
Introduction to Node.JS
 
Beginners Node.js
Beginners Node.jsBeginners Node.js
Beginners Node.js
 
Building Applications With the MEAN Stack
Building Applications With the MEAN StackBuilding Applications With the MEAN Stack
Building Applications With the MEAN Stack
 
Kalp Corporate Node JS Perfect Guide
Kalp Corporate Node JS Perfect GuideKalp Corporate Node JS Perfect Guide
Kalp Corporate Node JS Perfect Guide
 
Proposal
ProposalProposal
Proposal
 
Node js
Node jsNode js
Node js
 
Real time web
Real time webReal time web
Real time web
 
NodeJS and what is actually does
NodeJS and what is actually doesNodeJS and what is actually does
NodeJS and what is actually does
 
Quick introduction to nodeJs
Quick introduction to nodeJsQuick introduction to nodeJs
Quick introduction to nodeJs
 
Node.js Web Development .pdf
Node.js Web Development .pdfNode.js Web Development .pdf
Node.js Web Development .pdf
 
GlobalsDB: Its significance for Node.js Developers
GlobalsDB: Its significance for Node.js DevelopersGlobalsDB: Its significance for Node.js Developers
GlobalsDB: Its significance for Node.js Developers
 
02 Node introduction
02 Node introduction02 Node introduction
02 Node introduction
 
Day in a life of a node.js developer
Day in a life of a node.js developerDay in a life of a node.js developer
Day in a life of a node.js developer
 
Day In A Life Of A Node.js Developer
Day In A Life Of A Node.js DeveloperDay In A Life Of A Node.js Developer
Day In A Life Of A Node.js Developer
 
Node.js and .NET Core.pdf
Node.js and .NET Core.pdfNode.js and .NET Core.pdf
Node.js and .NET Core.pdf
 
Node.js Web Development.pdf
Node.js Web Development.pdfNode.js Web Development.pdf
Node.js Web Development.pdf
 
Nodejs
NodejsNodejs
Nodejs
 
All You Need to Know About Using Node.pdf
All You Need to Know About Using Node.pdfAll You Need to Know About Using Node.pdf
All You Need to Know About Using Node.pdf
 
Node
NodeNode
Node
 
What is Node.js_ Where, When & How To Use It.pdf
What is Node.js_ Where, When & How To Use It.pdfWhat is Node.js_ Where, When & How To Use It.pdf
What is Node.js_ Where, When & How To Use It.pdf
 

Recently uploaded

WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...masabamasaba
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024VictoriaMetrics
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...chiefasafspells
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburgmasabamasaba
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfonteinmasabamasaba
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...masabamasaba
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...masabamasaba
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...masabamasaba
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Bert Jan Schrijver
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park masabamasaba
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastPapp Krisztián
 

Recently uploaded (20)

WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaS
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 

Node js

  • 1. 21.02.2017 Fatih Şimşek - Software Infrastructure
  • 2. NodeJs Open Source, cross platform Huge community Ryan Dahl, Joyent Developed in 2009 Published in 2011 ( Linux + Windows ) Similar design to systems like Ruby's Event Machine or Python's Twisted
  • 3. Who is using NodeJs?
  • 4. Success Stories Yahoo: Node services handle around 1.680.000 – 2.000.000 requests/minute. Biggest Win: speed & ease of developement Netflix: The team decided to use Node.js to achieve lightweight, modular and fast application. As a result, the startup time of their new app has been reduced by 70% Linkedin: When compared with the previous Ruby on Rails based version, the new mobile app is up to 20 times faster Walmart: %55 of all traffic on Black Friday went to Node servers. Not a single Node server went down
  • 5. Success Stories PayPal: Build a Node version of a Java app in half the time with fewer developers. Node version of the app doubled the number of requests/second. Request time dropped 35% Groupon: In comparison with earlier Ruby on Rails platform, web pages got faster by about 50% and are able to serve much higher traffic GoDaddy: 10x fewer servers to host our customer websites and we reduced the Time To First Byte (TTFB) considerably from ~60ms to something around ~12ms
  • 7. NodeJs Built on Chrome’s Javascript Runtime (V8) Single thread, event oriented Event-Driven with Non-blocking I/O Use a Event Loop for Non-blocking I/O Can handle thousands of concurrent connections with minimal overhead (CPU/Memory) 40% JS and 60% C++
  • 8. Traditional Server New thread per request The thread is blocked during IO operations
  • 9. Thesis IO is expensive Thread per connection is memory expensive
  • 10. Architecture 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 Response is sent back to main thread via callback Event loop returns result to client
  • 11. Architecture API in Javascript Relies on Google’s V8 runtime engine Node Bindings allow for server operations (IO, network) Libuv responsible for both asynchronous I/O & event loop
  • 12. When to use NodeJs? Highly Event driven & Heavily I/O bound Chat application Online game Collaboration tool Monitoring Dashboard Trader’s Dashboard
  • 13. When not to use NodeJs? Heavy CPU intensive calculations on server-side Concurrent Task based applications
  • 15. Developement Environment Web Storm Sublime Text Atom Nodeclipse Visual Studio Visual Studio Code
  • 16. DEMO
  • 17. Node Frameworks & Tools NPM (Package Manager) Gulp / Grunt Express.js Frameworks built on Express.js (LoopBack / MEAN / Sails) Restify Mongoose Socket.io
  • 18. NPM Package manager for Node Bundled and installed automatically with the environment Frequently Usage • npm install --save package_name • npm update How Does it works? • Read package.json • Installs the dependencies in the local node_modules folder • In global modes, it make a node module accessible to all
  • 19. Express.js Web application framework Minimal and Flexible Many Framework based on Express Features • MVC • Routing • Session Support • Cookie Parsing • Middleware (Request-Response Cycle) • View Engines (Jade, Ejs, Vash)
  • 20. Vash Familiar Razor engine experience No special template syntax to learn Syntax:
  • 21. Mongoose Object Data Modelling for Node.js Officially supported by 10gen,Inc Features: • Async and sync validation of models • Model casting • Object lifecycle management (hook save / validate) • Query Builder • Schema Deriven Design
  • 22. DEMO
  • 23.
  • 24. EventEmitter Most of built-in Node libraries use it Use Observer Pattern
  • 25. Socket.io Realtime application framework Cross browser (Web socket + fallback) Bi-directional communication Automatic compression IOS, Android, NativeScript support Two parts • Client side (run on browser) • Server side (run on Node)
  • 26. DEMO

Editor's Notes

  1. Ryan is an American freelance programmer living in of Germany. His work invariably involves interruptible parsers, event loops, and response time histograms. He is the creator of several open source projects including the Ebb web server and the "EY" load balancer module for Nginx. Joyent, ABD'nin San Fransisco kenti merkezli yazılım firması.
  2. 9 Famous Apps Built with Node.js https://brainhub.eu/blog/2016/05/30/9-famous-apps-using-node-js/
  3. 9 Famous Apps Built with Node.js https://brainhub.eu/blog/2016/05/30/9-famous-apps-using-node-js/
  4. Single thread to handle callbacks Ideal for waiting for I/O calls (network, filesystem, database) Not ideal for CPU intensive operations -> solution fork new child process No thread management No need to synchronization Creating scalable web servers is easy
  5. The request to read the file goes through Node bindings to libuv. Then libuv gives the task of reading the file to a thread. When the thread completes reading the file into the buffer, the results goes to V8 and then through the Node bindings in the form of a callback function. In the callback shown the data argument is a Buffer with the file data.
  6. Nodeclipse: Built on Eclipse
  7. Single Thread
  8. Restify = Rest API comes with automatic DTrace support for all your handlers, if you're running on a platform that supports Dtrace Dtrace is a comprehensive dynamic tracing framework created by Sun Microsystems for troubleshooting kernel and application problems on production systems in real time
  9. You can set request time before routing on middleware
  10. Jade / EJS = http://wildermuth.com/2014/3/24/Choose_Your_Own_Adventure_with_Node_js_View_Engines Vash = https://www.upnxt.com/blog/node-with-express-vash-sqlite http://kirbysayshi.com/2012/04/17/vash.html
  11. Table = Collection Record = Document http://www.slideshare.net/yuriybogomolov/ybo-mongo-dbmeetup
  12. Sample ExpressJs http://getbootstrap.com/css/#forms http://getbootstrap.com/components/#list-group http://getbootstrap.com/components/#glyphicons-examples
  13. You can crete your Node Libraries build on EventEmitter EventEmitter functions : addListener(event, listener) on(event, listener) once(event, listener) removeListener(event, listener) removeAllListeners([event]) setMaxListeners(n) listeners(event) listenerCount(emitter, event)
  14. Web socket is not fully supported in all browser yet. İf Web socket is available, we will use it, if it is not, it will try fallback transports until one of them works Fallback tranports: Web sockets Flash sockets Ajax long polling Ajax streaming İframe Json polling
  15. Socket.io
  16. https://gist.github.com/ilyaigpetrov/f6df3e6f825ae1b5c7e2 https://tipaltilabs.com/2016/07/09/node-js-vs-iis-webapi-async/ OWIN idea on Asp.net after Nodejs
  17. http://www.wintellect.com/devcenter/jlane/five-reasons-asp-net-developers-should-care-about-node-js http://www.hanselman.com/blog/InstallingAndRunningNodejsApplicationsWithinIISOnWindowsAreYouMad.aspx