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
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++
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
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)
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)
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ı.
9 Famous Apps Built with Node.js
https://brainhub.eu/blog/2016/05/30/9-famous-apps-using-node-js/
9 Famous Apps Built with Node.js
https://brainhub.eu/blog/2016/05/30/9-famous-apps-using-node-js/
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
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.
Nodeclipse: Built on Eclipse
Single Thread
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
You can set request time before routing on middleware
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)
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
Socket.io
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